win32 乙個用API實現的對話方塊例項

2021-06-07 08:30:03 字數 2891 閱讀 9773

用到的檔案有

dialog.c

makefile

resource.h

resource.rc

1.dialog.c

#include #include #include "resource.h"

tchar dlgname=text("mydialog");

//tchar teststring=text("hello world");

tchar buffer1[512];

tchar buffer2[512];

tchar *buffer3=null;

int a=0,b=0,c=0;

hinstance g_hinstance;

int_ptr callback winproc(hwnd hwnd,uint msg,wparam wparam,lparam lparam);

int winapi winmain( hinstance hinstance, hinstance hprevinstance, lpstr lpcmdline, int nshowcmd )

int_ptr callback winproc(hwnd hwnd,uint msg,wparam wparam,lparam lparam)

}else}}

break;

default:

return false;

}return true;

}

2.makefile

dialog.exe:dialog.o resource.o

cc -o dialog.exe -mwindows dialog.o resource.o

dialog.o:windows.h tchar.h resource.h

resource.o:

windres -i resource.rc -o resource.o

vpath=c:\mingw\include

.phony:clean

clean:

del dialog.exe dialog.o resource.o

3.resource.h

#define idd_dialog1                     101

#define idr_menu1 102

#define idr_menu2 103

#define idc_edit1 1001

#define idc_edit2 1002

#define idc_edit3 1003

#define id_testcontrol_gettext 40001

#define id_testcontrol_cleartext 40002

#define id_testcontrol_exit 40003

// next default values for new objects

// #ifdef apstudio_invoked

#ifndef apstudio_readonly_symbols

#define _aps_next_resource_value 104

#define _aps_next_command_value 40004

#define _aps_next_control_value 1004

#define _aps_next_symed_value 101

#endif

#endif

4.resource.rc

#include "resource.h"

#include /

//// menu

//idr_menu2 menu discardable

begin

popup "test control"

begin

menuitem "get text", id_testcontrol_gettext

menuitem "clear text", id_testcontrol_cleartext

menuitem "exit", id_testcontrol_exit

endend/

//// dialog

//mydialog dialogex 0, 0, 419, 204

style ds_setfont | ds_modalframe | ds_3dlook | ds_fixedsys | ds_center | ws_minimizebox | ws_visible | ws_caption | ws_sysmenu

caption "dialog"

menu idr_menu2

font 8, "ms shell dlg", 400, 0, 0x1

begin

defpushbutton "確定",idok,181,10,50,14

pushbutton "取消",idcancel,185,31,50,14

edittext idc_edit1,27,9,50,17,es_autohscroll

edittext idc_edit2,101,8,52,18,es_autohscroll

edittext idc_edit3,63,35,51,17,es_autohscroll

end

win32彙編使用win32 api實現字串拷貝

字串拷貝,呼叫win32的lstrcpy函式 拷貝了以後用訊息框顯示一下 386 model flat,stdcall option casemap none include s masm32 include windows.inc include s masm32 include user32.i...

Win32 程序相關的API

開啟程序控制代碼 通過程序id 開啟模組控制代碼 基址 根據程序控制代碼 模組名 獲取模組的檔案全路徑 根據程序控制代碼 模組控制代碼 獲取模組的檔名 根據程序控制代碼 模組控制代碼 獲取模組的映象大小 入口位址 通過程序控制代碼 模組起始位址 讀取程序的記憶體 獲取程序的所有模組的控制代碼 inc...

如何建立乙個win32程式

首先要寫類似於main函式的winmain,int winapi winmain hinstance hinstance,hinstance hprevinstance,lpstr lpcmdline,int ncmdshow winapi是幹什麼的呢?它是呼叫宣告,相當於 stdcal。c 預設的...