谁有用 C (SDK) 写对话框的程序框架?(50分)

  • 主题发起人 主题发起人 QSmile
  • 开始时间 开始时间
Q

QSmile

Unregistered / Unconfirmed
GUEST, unregistred user!
谁有用 C (SDK) 写对话框的程序框架?<br><br>用 DialogBoxParam 的。<br>我写了一个运行不显示。我是用 MASM 写的。<br>可能程序结构有问题,我想看看 C 是怎样写的。
 
我试出来了!用 MASM 写的.<br><br>.386<br>.model flat ,stdcall<br><br>include windows.inc<br>include kernel32.inc<br>include user32.inc<br>include Comctl32.inc <br>include gdi32.inc<br><br>includelib kernel32.lib<br>includelib user32.lib<br>includelib Comctl32.lib<br>includelib gdi32.lib<br><br>.const<br>&nbsp; IDD_MAIN &nbsp;dd 1000<br>&nbsp; IDC_BTNOK dd 1002<br>&nbsp; <br>.data<br>szCaption &nbsp; db 'Dialog',0<br>szMsg &nbsp; &nbsp; &nbsp; db 'Program Run OK!',0<br>szError &nbsp; &nbsp; db 'Error',0<br><br>hInst dd ?<br><br>.data?<br><br>DlgProc proto :HWND,:UINT,:WPARAM,:LPARAM<br><br>.code<br>start:<br>&nbsp; invoke GetModuleHandle,NULL<br>&nbsp; mov hInst ,eax<br>&nbsp; invoke InitCommonControls<br>&nbsp; invoke DialogBoxParam,hInst,IDD_MAIN,NULL,Addr DlgProc,NULL<br>&nbsp; invoke ExitProcess,NULL<br><br>DlgProc proc hDlg:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM<br>&nbsp; &nbsp; <br>&nbsp; &nbsp; mov eax ,uMsg<br>&nbsp; &nbsp; .if eax == WM_CLOSE <br>&nbsp; &nbsp; &nbsp; &nbsp; invoke EndDialog,hDlg,NULL<br>&nbsp; &nbsp; .elseif eax == WM_COMMAND<br>&nbsp; &nbsp; &nbsp; &nbsp; mov eax ,wParam<br>&nbsp; &nbsp; &nbsp; &nbsp; .if eax == IDC_BTNOK <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; invoke MessageBox,hDlg,Addr szMsg,Addr szCaption,MB_ICONINFORMATION<br>&nbsp; &nbsp; &nbsp; &nbsp; .endif<br>&nbsp; &nbsp; .endif<br>&nbsp; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; xor eax,eax<br>&nbsp; &nbsp; ret<br><br>DlgProc endp<br>&nbsp; <br>end start
 
#include "stdafx.h"<br>#include "Resource.h"<br><br>BOOL CALLBACK MainDialogProc(<br>&nbsp; HWND hwndDlg, &nbsp;// handle to dialog box<br>&nbsp; UINT uMsg, &nbsp; &nbsp; // message<br>&nbsp; WPARAM wParam, // first message parameter<br>&nbsp; LPARAM lParam &nbsp;// second message parameter<br>);<br>&nbsp;<br><br>int APIENTRY WinMain(HINSTANCE hInstance,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HINSTANCE hPrevInstance,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LPSTR &nbsp; &nbsp; lpCmdLine,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int &nbsp; &nbsp; &nbsp; nCmdShow)<br>{<br>&nbsp; // TODO: Place code here.<br><br> if(-1 == DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG_PHONE), NULL, MainDialogProc))<br> {<br> MessageBox(0, "Can't Create Dialog", "Error", MB_OK | MB_ICONSTOP);<br> }<br><br> return 0;<br>}<br><br><br>BOOL CALLBACK MainDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)<br>{<br> switch(uMsg)<br> {<br> case WM_INITDIALOG:<br><br> return TRUE; // if you did not set focus to a control<br> break;<br> case WM_CLOSE:<br> EndDialog(hwndDlg, 0);<br> break;<br><br> case WM_COMMAND:<br> switch(LOWORD(wParam))<br> {<br> case IDC_BUTTON_CLOSE:<br> EndDialog(hwndDlg, 0);<br> }<br> break;<br> }<br> return FALSE;<br>}<br><br>
 
如何在 SDK 中使用 Toolbar?
 
接受答案了.
 
后退
顶部