我用HDC hdc=::GetDC(hwnd);怎么,打开的窗口关闭了阿

bingtuohun 2007-04-30 12:50:26
CWnd* pWnd=CWnd::FindWindow(NULL,"新建 BMP 图像 (2).bmp - 画图");
HWND hwnd=pWnd->GetSafeHwnd();


HDC hdc=::GetDC(hwnd);
...全文
101 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
该代码是基于vc的数据可视化功能 #include #include LRESULT CALLBACK WangProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd ) { WNDCLASS wndcls; wndcls.cbClsExtra=0; wndcls.cbWndExtra=0; wndcls.hbrBackground=NULL;//(HBRUSH)GetStockObject(BLACK_BRUSH); wndcls.hCursor=LoadCursor(NULL,IDC_NO); wndcls.hIcon=LoadIcon(NULL,IDI_ERROR); wndcls.hInstance=hInstance; wndcls.lpfnWndProc=WangProc; wndcls.lpszClassName="王朝帅"; wndcls.lpszMenuName=NULL; wndcls.style=CS_VREDRAW | CS_PARENTDC/* | CS_HREDRAW*/; RegisterClass(&wndcls); HWND hwnd; hwnd=CreateWindow("王朝帅","安徽大学 计算机科学与技术学院 王朝帅",WS_OVERLAPPEDWINDOW, 50,50,600,400,0,0,0,NULL); ShowWindow(hwnd,SW_SHOWNORMAL); UpdateWindow(hwnd); MSG msg; while(GetMessage(&msg,hwnd,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return 0; } LRESULT CALLBACK WangProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { switch(uMsg) { case WM_CHAR: char szChar[20]; sprintf(szChar,"char is '%c'",wParam); MessageBox(hwnd,szChar,"朝帅作品",MB_OK); break; case WM_LBUTTONDOWN: MessageBox(hwnd,"mouse clicked","朝帅作品",MB_OK); HDC hdc; hdc=GetDC(hwnd); TextOut(hdc,0,50,"MFC学习中心--朝帅作品",strlen("MFC学习中心--朝帅作品")); ReleaseDC(hwnd,hdc); break; case WM_PAINT: HDC hDC; PAINTSTRUCT ps; hDC=BeginPaint(hwnd,&ps); TextOut(hDC,0,0,"MFC培训",strlen("MFC培训")); EndPaint(hwnd,&ps); break; case WM_CLOSE: if(IDYES==MessageBox(hwnd,"是否真的结束?","朝帅作品",MB_YESNO)) { DestroyWindow(hwnd); } break; case WM_DESTROY: PostQuitMessage(1); break; default: return DefWindowProc(hwnd,uMsg,wParam,lParam); } return 0; }

2,100

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧