|
这个程序几乎是从教程上照搬下来的,总是不能运行成功,说生成窗口失败。
大家帮我看看原因,谢谢了。
我上传了附件,很小,只有5k,可以下载在vc6下跑一下看。
---------------------------myDlg.cpp----------------------------------
#include <windows.h>
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("myDlg") ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = DLGWINDOWEXTRA ; // Note!
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (hInstance, szAppName) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
if (!RegisterClass (&wndclass))
{
MessageBox ( NULL, TEXT ("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}
hwnd = CreateDialog (hInstance, szAppName, 0, NULL) ;
if(!hwnd){
MessageBox(NULL, "create dialog failure!", "error", MB_ICONERROR);
return 1;
}
ShowWindow (hwnd, iCmdShow) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam,LPARAM lParam)
{
switch (message)
{
case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}
----------------------------------------------------------------------------------
----------------------myDlg.rc------------------------------------------
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#include "afxres.h"
myDlg DIALOG DISCARDABLE 0, 0, 187, 66
STYLE WS_OVERLAPPED| WS_CAPTION | WS_SYSMENU
CLASS "myDlg"
CAPTION "sdk对话框"
CLASS "myDlg"
FONT 10, "System"
BEGIN
END
myDlg ICON DISCARDABLE "icon1.ico"
------------------------------------------------------------------
----------------------resource.h---------------------------------
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by myDlg.rc
//
#define myDlg 101
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 103
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
---------------------------------------------------------
|
|