CreateIC()和CreateDC()都获取设备描述表句柄,但用CreateDC()获取的能够进行绘画,而用CreateIC()获取的设备描述表,你却不能用它往设备上写东西,只能查询获取你所要的信息。测试代码如下:

   #include <windows.h>
CreatDC()和CreateIC()
CreatDC()和CreateIC()LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
CreatDC()和CreateIC()
CreatDC()和CreateIC()
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
CreatDC()和CreateIC()                    PSTR szCmdLine, 
int iCmdShow)
CreatDC()和CreateIC()CreatDC()和CreateIC()
{
CreatDC()和CreateIC()     
static TCHAR szAppName[] = TEXT ("HelloWin") ;
CreatDC()和CreateIC()     HWND         hwnd ;
CreatDC()和CreateIC()     MSG          msg ;
CreatDC()和CreateIC()     WNDCLASS     wndclass ;
CreatDC()和CreateIC()
CreatDC()和CreateIC()     wndclass.style         
= CS_HREDRAW | CS_VREDRAW ;
CreatDC()和CreateIC()     wndclass.lpfnWndProc   
= WndProc ;
CreatDC()和CreateIC()     wndclass.cbClsExtra    
= 0 ;
CreatDC()和CreateIC()     wndclass.cbWndExtra    
= 0 ;
CreatDC()和CreateIC()     wndclass.hInstance     
= hInstance ;
CreatDC()和CreateIC()     wndclass.hIcon         
= LoadIcon (NULL, IDI_APPLICATION) ;
CreatDC()和CreateIC()     wndclass.hCursor       
= LoadCursor (NULL, IDC_ARROW) ;
CreatDC()和CreateIC()     wndclass.hbrBackground 
= (HBRUSH) GetStockObject (WHITE_BRUSH) ;
CreatDC()和CreateIC()     wndclass.lpszMenuName  
= NULL ;
CreatDC()和CreateIC()     wndclass.lpszClassName 
= szAppName ;
CreatDC()和CreateIC()
CreatDC()和CreateIC()     
if (!RegisterClass (&wndclass))
CreatDC()和CreateIC()     
{
CreatDC()和CreateIC()          MessageBox (NULL, TEXT (
"This program requires Windows NT!"), 
CreatDC()和CreateIC()                      szAppName, MB_ICONERROR) ;
CreatDC()和CreateIC()          
return 0 ;
CreatDC()和CreateIC()     }

CreatDC()和CreateIC()     
CreatDC()和CreateIC()     hwnd 
= CreateWindow (szAppName,                  // window class name
CreatDC()和CreateIC()
                          TEXT ("The Hello Program"), // window caption
CreatDC()和CreateIC()
                          WS_OVERLAPPEDWINDOW,        // window style
CreatDC()和CreateIC()
                          CW_USEDEFAULT,              // initial x position
CreatDC()和CreateIC()
                          CW_USEDEFAULT,              // initial y position
CreatDC()和CreateIC()
                          CW_USEDEFAULT,              // initial x size
CreatDC()和CreateIC()
                          CW_USEDEFAULT,              // initial y size
CreatDC()和CreateIC()
                          NULL,                       // parent window handle
CreatDC()和CreateIC()
                          NULL,                       // window menu handle
CreatDC()和CreateIC()
                          hInstance,                  // program instance handle
CreatDC()和CreateIC()
                          NULL) ;                     // creation parameters
CreatDC()和CreateIC()
     
CreatDC()和CreateIC()     ShowWindow (hwnd, iCmdShow) ;
CreatDC()和CreateIC()     UpdateWindow (hwnd) ;
CreatDC()和CreateIC()     
CreatDC()和CreateIC()     
while (GetMessage (&msg, NULL, 00))
CreatDC()和CreateIC()CreatDC()和CreateIC()     
{
CreatDC()和CreateIC()          TranslateMessage (
&msg) ;
CreatDC()和CreateIC()          DispatchMessage (
&msg) ;
CreatDC()和CreateIC()     }

CreatDC()和CreateIC()     
return msg.wParam ;
CreatDC()和CreateIC()}

CreatDC()和CreateIC()
CreatDC()和CreateIC()LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
CreatDC()和CreateIC()CreatDC()和CreateIC()
{
CreatDC()和CreateIC()     
static HDC  hdcScreen ;
CreatDC()和CreateIC()    

CreatDC()和CreateIC()   

CreatDC()和CreateIC()
     
CreatDC()和CreateIC()     
switch (message)
CreatDC()和CreateIC()CreatDC()和CreateIC()     
{
CreatDC()和CreateIC()     
case WM_CREATE:
CreatDC()和CreateIC()          hdcScreen 
= CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
CreatDC()和CreateIC()          
//hdcScreen = CreateIC(TEXT("DISPLAY"), NULL, NULL, NULL);
CreatDC()和CreateIC()
         return 0 ;

CreatDC()和CreateIC()      
         
CreatDC()和CreateIC()     
case WM_PAINT:
CreatDC()和CreateIC()          TextOut(hdcScreen, 
5050, TEXT("xiexiufeng"), 11);
CreatDC()和CreateIC()          
return 0 ;
CreatDC()和CreateIC()          
CreatDC()和CreateIC()     
case WM_DESTROY:
CreatDC()和CreateIC()          DeleteDC(hdcScreen);
CreatDC()和CreateIC()          PostQuitMessage (
0) ;
CreatDC()和CreateIC()          
return 0 ;
CreatDC()和CreateIC()     }

CreatDC()和CreateIC()     
return DefWindowProc (hwnd, message, wParam, lParam) ;
CreatDC()和CreateIC()}
   可是,为什么要用CreateIC()呢,CreateDC()已经可以满足我们所有的需要呢!查了下msdn:
   The CreateIC function creates an information context for the specified device. The information context provides a fast way to get information about the device without creating a device context. 
   从中可以看出CreateIC()函数要必CreateDC()快。至于为什么快,其原理说来起来容易。CreateDC()不仅要获取信息,还要使其能够被修改。而CreateIC()只需要其能获得信息就行了。但,真正理解其中的东西,还需要解读这两个函数的源码吧。(这好像看起来不现实)

相关文章:

  • 2021-11-25
  • 2022-02-20
  • 2022-02-08
  • 2022-01-03
  • 2022-01-12
  • 2021-06-20
  • 2021-11-25
  • 2021-12-10
猜你喜欢
  • 2022-12-23
  • 2021-08-19
  • 2021-10-25
  • 2021-08-17
  • 2021-12-01
  • 2022-12-23
相关资源
相似解决方案