永发信息网

C++在做windows程序设计时,窗口和窗口类这两个概念有什么区别?

答案:2  悬赏:30  手机版
解决时间 2021-02-27 21:58
  • 提问者网友:暮烟疏雨之际
  • 2021-02-27 15:00
C++在做windows程序设计时,窗口和窗口类这两个概念有什么区别?
最佳答案
  • 五星知识达人网友:三千妖杀
  • 2021-02-27 16:18
你说的类是源码的那个抽象类还是API中的类,麻烦你把你的问题描述清楚。
全部回答
  • 1楼网友:你可爱的野爹
  • 2021-02-27 17:03
就会第一题,第二题的gui没有研究,以下是c++程序代码: #include hdc hdc; paintstruct ps; rect rect; lresult callback wndproc (hwnd, uint, wparam, lparam) ; int winapi winmain (hinstance hinstance, hinstance hprevinstance, pstr szcmdline, int ncmdshow) { static tchar szappname []="applicaiton"; hwnd hwnd; wndclass wndcls; msg msg; wndcls.cbclsextra=0; wndcls.cbwndextra=0; wndcls.hbrbackground=(hbrush)getstockobject(white_brush); wndcls.hcursor=loadcursor(null,idc_arrow); wndcls.hicon=loadicon(null,idi_application); wndcls.hinstance=hinstance; wndcls.lpfnwndproc=wndproc; wndcls.lpszmenuname=null; wndcls.lpszclassname=szappname; wndcls.style=cs_hredraw|cs_vredraw; if(!registerclass(&wndcls)) { messagebox(null,"error","error",mb_iconerror); return 0; } hwnd=createwindowex(ws_ex_topmost, szappname, "windows窗口程序demo", ws_overlappedwindow, 0,0, 400,300, null,null, hinstance, null); showwindow(hwnd,ncmdshow); updatewindow(hwnd); dword start_time; while(true) { hdc=getdc(hwnd); start_time=gettickcount(); if(peekmessage(&msg,null,0,0,pm_remove)) { if(msg.message==wm_quit) break; translatemessage(&msg); dispatchmessage(&msg); } getclientrect (hwnd, &rect) ; fillrect(hdc,&rect,createsolidbrush(rgb(rand()%255,rand()%255,rand()%255))); while(gettickcount()-start_time<250) {} releasedc(hwnd,hdc); } return msg.wparam; } lresult callback wndproc (hwnd hwnd, uint msg, wparam wapram, lparam lapram) { switch(msg) { case wm_paint: { hdc = beginpaint (hwnd, &ps) ; getclientrect (hwnd, &rect) ; fillrect(hdc,&rect,createsolidbrush(rgb(rand()%255,rand()%255,rand()%255))); endpaint (hwnd, &ps) ; return 0; } break; case wm_destroy: { postquitmessage (0) ; return 0 ; } break; } return defwindowproc (hwnd, msg, wapram, lapram) ; } 注意:最后在菜单栏选择工程->设置->链接,或者快捷键 alt+f7,调出对话框,将工程选项的subsystem:console的console改为windows,嘿嘿!!! 搞定,运行即可。哈哈 由于这个程序使用的是gdi函数直接调用,没有优化,比较占资源,刚开始反映可能会有些迟钝。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯