#include <windows.h>
#include <stdio.h>/*
LRESULT CALLBACK WinLiuProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
*/
class CWnd
{
public:
BOOL CreateEx(DWORD dwExStyle,LPCTSTR lpClassName,LPCTSTR lpWindowName,DWORD dwStyle,int x, int y,
int nWidth, int nHeight,HWND hWndParent,HMENU nMenu,HINSTANCE hInstance,
LPVOID lpParam);
public :
BOOL ShowWindow(int nCmdShow);
BOOL UpdateWindow();
HWND m_hwnd;
};
BOOL CWnd::CreateEx(DWORD dwExStyle,LPCTSTR lpClassName,LPCTSTR lpWindowName,DWORD dwStyle,int x, int y,
int nWidth, int nHeight,HWND hWndParent,HMENU nMenu,HINSTANCE hInstance,
LPVOID lpParam)
{
m_hwnd=::CreateWindowEx(dwExStyle, lpClassName,lpWindowName,dwStyle,x,y,nWidth,
nHeight,hWndParent,nMenu,hInstance,lpParam );
if(m_hwnd!=NULL)
return TRUE;
else
return FALSE;
}
BOOL CWnd::ShowWindow(int nCmdShow)
{
return ::ShowWindow (m_hwnd,nCmdShow);
}BOOL CWnd::UpdateWindow()
{
return ::UpdateWindow(m_hwnd);
} int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // pointer to command line
int nCmdShow // show state of window
){
WNDCLASS wndclass;
wndclass.cbClsExtra =0;
wndclass.cbWndExtra=0;
wndclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wndclass.hCursor =LoadIcon((HINSTANCE) NULL, IDI_APPLICATION);
wndclass.hCursor=LoadCursor((HINSTANCE) NULL, IDC_ARROW);
wndclass.hInstance=hInstance;
// wndclass.lpfnWndProc =WinLiuProc;
wndclass.lpszClassName ="GT.TOM";
wndclass.lpszMenuName="NULL";
wndclass.style=CS_HREDRAW|CS_VREDRAW;
RegisterClass(&wndclass);
//////////////////////////////////////////////////////////////////////////
CWnd wnd;
wnd.CreateEx(WS_EX_CLIENTEDGE,"GT.TOM","liugt",WS_BORDER,50, 50,
600,400,NULL ,NULL ,hInstance,NULL); wnd.ShowWindow(SW_SHOWNORMAL);
wnd.UpdateWindow();
//////////////////////////////////////////////////////////////////////////
MSG msg;
while (GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
/* HWND hwnd;
hwnd=CreateWindowEx();
::ShowWindow(hwnd,SW_SHOWNORMAL);
::UpdateWindow(hwnd);
*/
}任务栏管理器中WinMain.exe有运行,但为什么窗口不显示呢?跪求解答
#include <stdio.h>/*
LRESULT CALLBACK WinLiuProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
*/
class CWnd
{
public:
BOOL CreateEx(DWORD dwExStyle,LPCTSTR lpClassName,LPCTSTR lpWindowName,DWORD dwStyle,int x, int y,
int nWidth, int nHeight,HWND hWndParent,HMENU nMenu,HINSTANCE hInstance,
LPVOID lpParam);
public :
BOOL ShowWindow(int nCmdShow);
BOOL UpdateWindow();
HWND m_hwnd;
};
BOOL CWnd::CreateEx(DWORD dwExStyle,LPCTSTR lpClassName,LPCTSTR lpWindowName,DWORD dwStyle,int x, int y,
int nWidth, int nHeight,HWND hWndParent,HMENU nMenu,HINSTANCE hInstance,
LPVOID lpParam)
{
m_hwnd=::CreateWindowEx(dwExStyle, lpClassName,lpWindowName,dwStyle,x,y,nWidth,
nHeight,hWndParent,nMenu,hInstance,lpParam );
if(m_hwnd!=NULL)
return TRUE;
else
return FALSE;
}
BOOL CWnd::ShowWindow(int nCmdShow)
{
return ::ShowWindow (m_hwnd,nCmdShow);
}BOOL CWnd::UpdateWindow()
{
return ::UpdateWindow(m_hwnd);
} int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // pointer to command line
int nCmdShow // show state of window
){
WNDCLASS wndclass;
wndclass.cbClsExtra =0;
wndclass.cbWndExtra=0;
wndclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wndclass.hCursor =LoadIcon((HINSTANCE) NULL, IDI_APPLICATION);
wndclass.hCursor=LoadCursor((HINSTANCE) NULL, IDC_ARROW);
wndclass.hInstance=hInstance;
// wndclass.lpfnWndProc =WinLiuProc;
wndclass.lpszClassName ="GT.TOM";
wndclass.lpszMenuName="NULL";
wndclass.style=CS_HREDRAW|CS_VREDRAW;
RegisterClass(&wndclass);
//////////////////////////////////////////////////////////////////////////
CWnd wnd;
wnd.CreateEx(WS_EX_CLIENTEDGE,"GT.TOM","liugt",WS_BORDER,50, 50,
600,400,NULL ,NULL ,hInstance,NULL); wnd.ShowWindow(SW_SHOWNORMAL);
wnd.UpdateWindow();
//////////////////////////////////////////////////////////////////////////
MSG msg;
while (GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
/* HWND hwnd;
hwnd=CreateWindowEx();
::ShowWindow(hwnd,SW_SHOWNORMAL);
::UpdateWindow(hwnd);
*/
}任务栏管理器中WinMain.exe有运行,但为什么窗口不显示呢?跪求解答
就简单使用createWindow()就可以了 为什么使用这段代码:CWnd wnd;
wnd.CreateEx(WS_EX_CLIENTEDGE,"GT.TOM","liugt",WS_BORDER,50, 50,
600,400,NULL ,NULL ,hInstance,NULL); wnd.ShowWindow(SW_SHOWNORMAL);
wnd.UpdateWindow();把这段代码换成正常API的,加入你上面注册的窗口类的数据填写的参数,肯定就可以了。
然后查看里面的创建窗口的代码,你就知道怎么写了。
窗口是显示在显示器上的(对应于内存的数据)的一个框框; 窗口类是在系统中注册的一个窗口类别,用这个系统注册用的窗口类别去创建一个窗口。 窗口类对象这个词好别扭;
注意API里是没有类的。窗口类 指的不是c++的class 而是在系统里注册了的一个东西而已。相当于数据类型吧(晕,真蹩脚),就象struct一样。。
郁闷 不说了。哪来这么多概念,编程序 道理懂了就行, 没概念之说。
想到那些面向对象的书一上来花一两章吹面向对象的好处就烦。咕隆玄虚。
wndclass.hCursor =LoadIcon((HINSTANCE) NULL, IDI_APPLICATION); ->改成hIcon
wndclass.lpszMenuName="NULL";------>把引号去掉
就OK了!不过依然谢谢你们!