64,648
社区成员
发帖
与我相关
我的任务
分享
if(menu.GetMenuHandle() != NULL) _menu = menu.GetMenuHandle();
case WM_PAINT:
hdc = BeginPaint(hwnd,&ps);
EndPaint(hwnd, &ps);
return 0;
break;
LRESULT CALLBACK winProc(HWND hwnd, UINT message, WPARAM lParam , LPARAM wParam)
{
PAINTSTRUCT ps;
HDC hdc;
switch(message)
{
case WM_CREATE:
return 0;
break;
case WM_PAINT:
hdc = BeginPaint(hwnd,&ps);
EndPaint(hwnd, &ps);
return 0;
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default: break;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
#ifndef LJMENU_
#define LJMENU_
#include <windows.h>
namespace LJ
{
class Menu
{
public:
Menu(HMENU menu){_menuHandle = menu;}
~Menu(){};
HMENU GetMenuHandle(){return _menuHandle;}
private:
HMENU _menuHandle;
};
}
#endif
ifndef WNDCLASS_
#define WNDCLASS_
#include <windows.h>
#include "LJMenu.h"
namespace LJ
{
class WinClass
{
public:
WinClass(HINSTANCE instance,LRESULT CALLBACK (*winProc)(HWND hwnd, UINT message, WPARAM lParam , LPARAM wParam) ,LPSTR name,UINT style = CS_VREDRAW|CS_HREDRAW|CS_OWNDC|CS_DBLCLKS);
~WinClass(){}
void SetStyle(DWORD);
void SetMenu(Menu);
HINSTANCE GetInstance(){return _instance;}
private:
HINSTANCE _instance;
WNDCLASS _winClass;
HANDLE _icon;
HANDLE _cursor;
HMENU _menu;
};
}
#endif
#include "LJApplication.h"
LJ::WinClass::WinClass(HINSTANCE instance,LRESULT CALLBACK (*winProc)(HWND hwnd, UINT message, WPARAM lParam , LPARAM wParam) ,LPSTR name,UINT _style)
{
_instance = instance;
_winClass.style = _style;
_winClass.lpfnWndProc = winProc;
_winClass.cbClsExtra = 0;
_winClass.cbWndExtra = 0;
_winClass.hInstance = instance;
_winClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
_winClass.hCursor = LoadCursor(NULL, IDC_ARROW);
_winClass.hbrBackground= (HBRUSH)COLOR_BACKGROUND;
_winClass.lpszMenuName = NULL;
_winClass.lpszClassName= name;
if(!RegisterClass(&_winClass)) MessageBox(NULL,"注册失败","错误",MB_OK);
}
void LJ::WinClass::SetStyle(DWORD)
{
}
void LJ::WinClass::SetMenu(Menu)
{
}
#ifndef LJWINDOW_
#define LJWINDOW_
#include <windows.h>
#include "LJMenu.h"
namespace LJ
{
class Window
{
public:
Window(LPSTR winClass, LPSTR caption, HINSTANCE hInstance,int width = CW_USEDEFAULT, int height = CW_USEDEFAULT,DWORD style = WS_OVERLAPPEDWINDOW|WS_VISIBLE, HWND paren = NULL, LJ::Menu meun = NULL);
~Window(){}
void SetCaption(LPSTR);
void SetSize(int, int);
HWND& GetHandle(){return _winHandle;}
int GetWidth(){return _width;}
int GetHeight(){return _height;}
HWND GetParenHandle(){return _parentHandle;}
private:
HWND _winHandle;
HWND _parentHandle;
HMENU _menu;
LPSTR _titre;
int _width;
int _height;
};
void Show(Window& win, int mode);
}
#endif
#include "LJWindow.h"
LJ::Window::Window(LPSTR winClass, LPSTR caption, HINSTANCE hInstance,int width, int height,DWORD style, HWND parent, LJ::Menu menu)
{
if(menu.GetMenuHandle() != NULL) _menu = menu.GetMenuHandle();
_parentHandle = parent;
_winHandle = CreateWindow(winClass,
caption,
style,
CW_USEDEFAULT,
CW_USEDEFAULT,
width,
height,
parent,
_menu,
hInstance,
NULL);
}
void LJ::Window::SetCaption(LPSTR caption)
{
}
void LJ::Window::SetSize(int width, int height)
{
}
void LJ::Show(Window& win, int mode)
{
ShowWindow(win.GetHandle(), mode);
UpdateWindow(win.GetHandle());
}