/**************MyqqWnd.rc Written By XHK****************/
#include "resource.h"
#define DLG_MAIN 1
#define ICO_MAIN 0X1000
#define IDB_QQ 2
#define IDE_USER 0X4101 //帐号输入框
#define IDE_PASS 0X4102 //密码输入框
#define IDC_RECORD 0X4201 //记录密码复选框
#define IDC_AUTO 0X4202 //自动登录复选框
#define IDB_CHECK 0X4301 //查杀木马按钮
#define IDB_SET 0X4302 //设置按钮
#define IDB_SUBMIT 0X4303 //提交按钮
#define IDC_QQ 0X4304
ICO_MAIN ICON "qq.ico"
IDB_QQ BITMAP "qq.bmp"
DLG_MAIN DIALOG 255,205,222,145
STYLE WS_SYSMENU | WS_MINIMIZEBOX
CAPTION "QQ 2009 Made By XHK"
FONT 9,"宋体"
{
CONTROL "AAAAA",IDC_QQ,"Static",SS_BITMAP | WS_CHILD |
WS_VISIBLE,0,0,20,40
GROUPBOX "",-1,-1,48,224,75
RTEXT "帐号:",IDC_STATIC,14,55,20,15,SS_CENTERIMAGE
EDITTEXT IDE_USER,37,55,120,15,ES_NUMBER
LTEXT "注册新帐号",-1,160,55,50,15,SS_CENTERIMAGE
RTEXT "密码:",-1,14,75,20,15,SS_CENTERIMAGE
EDITTEXT IDE_PASS,37,75,120,15,ES_PASSWORD
LTEXT "取回密码",-1,160,75,45,15,SS_CENTERIMAGE
CHECKBOX "记住密码",IDC_RECORD,20,105,50,15
CHECKBOX "自动登录",IDC_AUTO,100,105,50,15
PUSHBUTTON "查杀木马",IDB_CHECK,5,125,50,15
PUSHBUTTON "设置",IDB_SET,60,125,50,15
DEFPUSHBUTTON "登录",IDB_SUBMIT,150,125,50,15
}
其实窗口代码跟上节的稍微不同:
#include <windows.h>
#define DLG_MAIN 1
#define ICO_MAIN 0X1000
#define IDB_QQ 2
#define IDE_USER 0X4101
#define IDE_PASS 0X4102
#define IDC_RECORD 0X4201
#define IDC_AUTO 0X4202
#define IDB_CHECK 0X4301
#define IDB_SET 0X4302
#define IDB_SUBMIT 0X4303
#define IDC_QQ 0X4304
LRESULT WINAPI DialogProc(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam)
{
HICON hIcon;
HWND hImage;
HBITMAP hBitmap;
HINSTANCE hInstance;
PAINTSTRUCT ps;
HDC hDC;
RECT rc;
switch(Msg)
{
case WM_INITDIALOG:
//设置窗口的图标
hInstance = GetModuleHandle(NULL);
hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(ICO_MAIN));
SendMessage(hWnd,WM_SETICON,ICON_BIG,(long)hIcon);
//加载那个图片qq.bmp
hBitmap = LoadBitmap(hInstance,MAKEINTRESOURCE(IDB_QQ));
hImage = GetDlgItem(hWnd,IDC_QQ);
SendMessage(hImage,STM_SETIMAGE,IMAGE_BITMAP,(long)hBitmap);
break;
case WM_PAINT:
//下面是给窗口填充为蓝色的背景
GetClientRect(hWnd,&rc);
hDC = BeginPaint(hWnd,&ps);
FillRect(hDC,&rc,(HBRUSH)CreateSolidBrush(RGB(200, 227, 255)));
//填充为蓝色
EndPaint(hWnd,&ps);
return 0;
case WM_CLOSE:
EndDialog(hWnd,0);
return TRUE;
}
return FALSE;
}
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPreInstance,
LPSTR lpCmdLine,
int nShowCmd)
{
DialogBoxParam(hInstance,MAKEINTRESOURCE(DLG_MAIN),NULL,DialogProc,0);
return 1;
}