请哪位高手帮我解决一下有关Windows编程的问题吧?
以下是我写的在Windows下建立一个窗口的程序,不知道为什么在注册窗口时总是返回0。希望哪位朋友能够帮我调一下,感激不尽,谢谢!
/*
Name: cMain.cpp
Copyright: Cite
Author: Chum Liu
Date: 10-10-03 08:48
Description: Main function, it will call cFrame class
*/
#include <windows.h>
#include "cFrame.h"
main()
{
cFrame* app = new cFrame();
app->lpClassName = NULL;
app->setTitle = "CiteSoft Logon";
app->BackStyle = CS_HREDRAW | CS_VREDRAW;
app->X = 200;
app->Y = 200;
app->Width = 400;
app->Height = 300;
app->hWndParent = NULL;
app->hMenu = NULL;
app->lpParam = NULL;
app->Show();
}
/*
Name: cFrame.h
Copyright: Cite
Author: Chum Liu
Date: 10-10-03 08:48
Description: Initialize windows
*/
#ifndef CFRAME_H_
#define CFRAME_H_
#include <windows.h>
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
class cFrame {
public:
LPCTSTR lpClassName;
LPCTSTR setTitle;
DWORD BackStyle;
int X, Y, Width, Height;
HWND hWndParent;
HMENU hMenu;
LPVOID lpParam;
cFrame();
int Show();
};
#endif
/*
Name: cFrame.cpp
Copyright: Cite
Author: Chum Liu
Date: 08-10-03 15:51
Description: Create window function in Windows NT
*/
#include <windows.h>
#include "cFrame.h"
/***********************************************************************
* Function for initialize window
*/
cFrame::cFrame() {
HINSTANCE hInstance;
static TCHAR szAppName[] = TEXT ("cWlogon") ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
cFrame cFrame;
wndclass.style = cFrame.BackStyle ;
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) GetStockObject (LTGRAY_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
if (!RegisterClass (&wndclass)) {
MessageBox (NULL, TEXT ("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}
}
/***********************************************************************
* Function for create window
*/
int cFrame::Show() {
HINSTANCE hInstance;
cFrame cFrame;
static TCHAR szAppName[] = TEXT ("cWlogon") ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
hwnd = CreateWindow (szAppName,
TEXT (cFrame.setTitle),
cFrame.BackStyle,
cFrame.X,
cFrame.Y,
cFrame.Width,
cFrame.Height,
cFrame.hWndParent,
cFrame.hMenu,
hInstance,
cFrame.lpParam) ;
ShowWindow (hwnd, SW_SHOWNOACTIVATE) ;
UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
LRESULT CALLBACK
WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static int cxChar, cxCaps, cyChar ;
HDC hdc ;
int i ;
PAINTSTRUCT ps ;
TCHAR szBuffer [10] ;
TEXTMETRIC tm ;
switch (message)
{
case WM_CREATE:
hdc = GetDC (hwnd) ;
GetTextMetrics (hdc, &tm) ;
cxChar = tm.tmAveCharWidth ;
cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar / 2 ;
cyChar = tm.tmHeight + tm.tmExternalLeading ;
ReleaseDC (hwnd, hdc) ;
return 0 ;
case WM_COMMAND:
switch( wParam )
{
}
break;
case WM_CLOSE:
DestroyWindow( hwnd );
return 0;
case WM_DESTROY :
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}
问题点数:0、回复次数:0Top




