我的程序如下,为什么运行后显示不了窗口呢?请指点
#include <windows.h>LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
static TCHAR szAppName[] = TEXT ("autooff") ; int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
WNDCLASS wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ; wndclass.lpfnWndProc = WndProc ; wndclass.cbClsExtra = 0 ; wndclass.cbWndExtra = 0 ; wndclass.hInstance = hInstance ; wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ; 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 hwnd;
hwnd=CreateDialog(hInstance,szAppName,NULL,NULL) ; ShowWindow (hwnd, iCmdShow) ; UpdateWindow (hwnd) ;
MSG msg ;
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_CREATE:
return 0; case WM_DESTROY: PostQuitMessage (0); return 0; } return DefWindowProc (hwnd, message, wParam, lParam);}
#include <windows.h>LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
static TCHAR szAppName[] = TEXT ("autooff") ; int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
WNDCLASS wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ; wndclass.lpfnWndProc = WndProc ; wndclass.cbClsExtra = 0 ; wndclass.cbWndExtra = 0 ; wndclass.hInstance = hInstance ; wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ; 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 hwnd;
hwnd=CreateDialog(hInstance,szAppName,NULL,NULL) ; ShowWindow (hwnd, iCmdShow) ; UpdateWindow (hwnd) ;
MSG msg ;
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_CREATE:
return 0; case WM_DESTROY: PostQuitMessage (0); return 0; } return DefWindowProc (hwnd, message, wParam, lParam);}
解决方案 »
- 编码转换器
- CString的变量如何转换成char*,已经上网查过了,但是我还是不懂?
- VS怎么改内编码
- 让人很抑郁的问题,请大侠进来看看
- 能不能通过一个小设备去改变主板的设置
- 有没有高手对NTFS有研究的?直接读扇区中目录索引信息,为什么极少数文件名会有一个字符是乱码?
- vc6程序中如何根据URL获取网页内容
- 程序开始时怎样才能设置Combo Box的默认值?
- 对像和指针问题
- 修改物理内存 分配权限问题
- sendmessage中关于EM_SETSEL消息的使用的问题?
- 我自定义了一个消息,为什么将消息响应函数写在CMainFrame中就好使,写在CMyView中就不好使呢?(在线等待,高分相赠)
hwnd=CreateDialog(hInstance,szAppName,NULL,WndProc ) 呢?
#include "resource.h" // 仅含 #define IDD_DIALOG 101#pragma code_page(936)IDD_DIALOG DIALOG DISCARDABLE 0, 0, 187, 100
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
CLASS "DIALOG_CLASS"
FONT 10, "@System"
{
DEFPUSHBUTTON "OK",IDOK,130,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,130,24,50,14
}// *.cpp 源代码
#include <windows.h>
#include "resource.h" // 仅含 #define IDD_DIALOG 101LRESULT CALLBACK DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_CLOSE:
PostQuitMessage(0);
return TRUE; case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
case IDCANCEL:
PostQuitMessage(0);
return TRUE;
}
break;
} return DefDlgProc(hWnd, uMsg, wParam, lParam);
}extern "C" int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE /*hPrevInstance*/, LPSTR lpCmdLine, int /*nShowCmd*/)
{
WNDCLASS wndclass = { 0 }; wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = DialogProc;
wndclass.cbWndExtra = DLGWINDOWEXTRA; // 重要
wndclass.hInstance = hInstance;
wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wndclass.lpszClassName = TEXT("DIALOG_CLASS"); // 同资源 RegisterClass(&wndclass); HWND hDialog =
CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG), NULL, NULL); ShowWindow(hDialog, SW_SHOW);
UpdateWindow(hDialog); MSG msg = { 0 }; while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
} return 0;
}