16,471
社区成员
发帖
与我相关
我的任务
分享
#include<Windows.h>
#include<stdio.h>
const char className[]="mywndclass";
LRESULT __stdcall myproc(HWND hWnd,UINT uMsg,WPARAM wp,LPARAM lp){
return 0L;
}
int __stdcall WinMain(
HINSTANCE hInst,
HINSTANCE hPrev,
LPSTR lpCmdLine,
int nCmdShow
){
WNDCLASSEX wnd;
ZeroMemory(&wnd,sizeof(wnd));
wnd.cbSize=sizeof(wnd);
wnd.lpszClassName=className;
wnd.lpszMenuName=NULL;
wnd.hInstance=hInst;
wnd.lpfnWndProc=myproc;
wnd.hbrBackground=(HBRUSH)MAKEINTRESOURCE(GRAY_BRUSH);
HWND hWnd=CreateWindowEx(0,className,"窗口名称",0,0,0,300,200,NULL,NULL,hInst,0);
if(INVALID_HANDLE_VALUE==hWnd){
MessageBox(NULL,"Error!","CreateWindowEx失败\n",MB_OK);
return 1;
}
if(!ShowWindow(hWnd,SW_SHOW)){
char dip[200];
sprintf(dip,"ShowWindow失败:%d\n",GetLastError());
MessageBox(NULL,"Error!",dip,MB_OK);
return 1;
}
return 0;
}
// test.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include<Windows.h>
#include<stdio.h>
char className[]="mywndclass";
LRESULT __stdcall myproc(HWND hWnd,UINT uMsg,WPARAM wp,LPARAM lp){
MSG msg;
while (GetMessage(&msg, (HWND) NULL, 0, 0) != 0 && GetMessage(&msg, (HWND) NULL, 0, 0) != -1)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
int __stdcall WinMain(
HINSTANCE hInst,
HINSTANCE hPrev,
LPSTR lpCmdLine,
int nCmdShow
){
WNDCLASSEX wnd;
ZeroMemory(&wnd,sizeof(wnd));
wnd.cbSize=sizeof(wnd);
wnd.lpszClassName=className;
wnd.lpszMenuName=NULL;
wnd.hInstance=hInst;
wnd.lpfnWndProc=myproc;
wnd.hbrBackground=(HBRUSH)MAKEINTRESOURCE(GRAY_BRUSH);
RegisterClassEx(&wnd);
HWND hWnd=CreateWindowEx(0,className,"窗口名称", WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL
,0,0,300,200,NULL,NULL,hInst,0);
if(!hWnd){
MessageBox(NULL,"Error!","CreateWindowEx失败\n",MB_OK);
return 1;
}
if(!ShowWindow(hWnd,SW_SHOW)){
char dip[200];
sprintf(dip,"ShowWindow失败:%d\n",GetLastError());
MessageBox(NULL,"Error!",dip,MB_OK);
return 1;
}
return 0;
}
#include<Windows.h>
#include<stdio.h>
const char className[]="mywndclass";
LRESULT __stdcall myproc(HWND hWnd,UINT uMsg,WPARAM wp,LPARAM lp){
return 0L;
}
int __stdcall WinMain(
HINSTANCE hInst,
HINSTANCE hPrev,
LPSTR lpCmdLine,
int nCmdShow
){
WNDCLASSEX wnd;
ZeroMemory(&wnd,sizeof(wnd));
wnd.cbSize=sizeof(wnd);
wnd.lpszClassName=className;
wnd.lpszMenuName=NULL;
wnd.hInstance=hInst;
wnd.lpfnWndProc=myproc;
wnd.hbrBackground=(HBRUSH)MAKEINTRESOURCE(GRAY_BRUSH);
ATOM reg;
if((reg=RegisterClassEx(&wnd))==0){
MessageBox(NULL,"RegisterClassEx失败\n","有错!",MB_OK);
return 1;
}
char dip[200];
HWND hWnd=CreateWindowEx(0,className,"窗口名称",
WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,0,0,300,200,NULL,NULL,hInst,0);
if(0==hWnd){
sprintf(dip,"CreateWindowEx失败:%d\n",GetLastError());
MessageBox(NULL,dip,"有错r!",MB_OK);
return 1;
}
if(!ShowWindow(hWnd,SW_SHOW)){
sprintf(dip,"ShowWindow失败:%d\n",GetLastError());
MessageBox(NULL,dip,"有错!",MB_OK);
return 1;
}
return 0;
}
RegisterClassEx(&wnd);
HWND hWnd=CreateWindowEx(0,className,"窗口名称", WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL
,0,0,300,200,NULL,NULL,hInst,0);
if(!hWnd){
MessageBox(NULL,"Error!","CreateWindowEx失败\n",MB_OK);
return 1;
}