看过文章,有用没用,有问题的,还请指点一二

  因为我也不知道有没有给大家带来一点用处。

  所以希望能多交流。

【静态控件】的使用。。还请各位高手指点一二。。

04-27

为什么静态控件不能显示Bitmap?rn源程如下:rnrn#include "stdafx.h"rn#include rn#include rn#include rn#include "resource.h"rnrnchar lpszClassName1[] = "static";rnchar lpszText[]="";rnHWND hwndStatic ;rnHINSTANCE hInst;rnHBITMAP hBm;rnBITMAP bm;rnrnLRESULT CALLBACK WndProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);rnrnint APIENTRY WinMain(HINSTANCE hInstance,rn HINSTANCE hPrevInstance,rn LPSTR lpCmdLine,rn int nCmdShow)rnrn // TODO: Place code here.rn HWND hWnd;rn MSG Msg;rn WNDCLASS WndClass;rnrnrn char lpszClassName[] = "控件";rn char lpszTitle[] = "静态控件";rn WndClass.cbClsExtra = 0;rn WndClass.cbWndExtra = 0;rn WndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);rn WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);rn WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);rn WndClass.hInstance = hInstance;rn WndClass.lpfnWndProc = WndProc;rn WndClass.lpszClassName = lpszClassName;rn WndClass.lpszMenuName = NULL;rn WndClass.style = 0;rnrn if(!RegisterClass(&WndClass))rn rn MessageBeep(0);rn return FALSE;rn rnrn hWnd = CreateWindow(lpszClassName, lpszTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);rn rn hBm = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP));rn GetObject(hBm, sizeof(BITMAP), (LPVOID)&bm);rn sprintf(lpszText,"该位图高度为%d, 宽度为%d。",bm.bmHeight, bm.bmWidth);rnrn ShowWindow(hWnd, nCmdShow);rn UpdateWindow(hWnd);rnrn hInst = hInstance;rnrn while(GetMessage(&Msg,0,0,0))rn rn TranslateMessage(&Msg);rn DispatchMessage(&Msg);rn rn return Msg.wParam;rnrnrnLRESULT CALLBACK WndProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)rnrn switch(message)rn rn case WM_CHAR:rn if (wparam == 27 )rn PostQuitMessage(0);rn break;rn case WM_CREATE:rn hwndStatic = CreateWindow(lpszClassName1,"IDB_BITMAP",rn WS_BORDER|WS_CHILD|WS_VISIBLE|SS_BITMAP|SS_NOTIFY,rn 30,30,rn 0,0, // autosizern hwnd,rn (HMENU)IDB_BITMAP,rn hInst,rn NULL);rn break;rn case WM_COMMAND:rn switch(LOWORD(wparam))rn rn case IDB_BITMAP:rn break;rn rn break;rn case WM_DESTROY:rn PostQuitMessage(0);rn break;rn rn return DefWindowProc(hwnd, message, wparam, lparam);rnrn

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试

关闭