欧美日韩不卡一区二区三区,www.蜜臀.com,高清国产一区二区三区四区五区,欧美日韩三级视频,欧美性综合,精品国产91久久久久久,99a精品视频在线观看

C語(yǔ)言

C語(yǔ)言創(chuàng)建windows窗口實(shí)例

時(shí)間:2025-05-23 06:24:12 C語(yǔ)言 我要投稿
  • 相關(guān)推薦

C語(yǔ)言創(chuàng)建windows窗口實(shí)例

  如何用C語(yǔ)言寫(xiě)出windows窗口程序?下面內(nèi)容由小編為大家介紹C語(yǔ)言創(chuàng)建windows窗口實(shí)例,供大家參考!

  步驟:

  1.在WinMain中定義各種變量

  2.注冊(cè)窗口類RegisterClass

  3.創(chuàng)建窗口CreateWindow

  4.顯示窗口和更新窗口

  復(fù)制代碼 代碼如下:

  ShowWindow (hwnd, iCmdShow) ;

  UpdateWindow (hwnd) ;

  5.消息循環(huán)

  復(fù)制代碼 代碼如下:

  while (GetMessage (&msg, NULL, 0, 0))

  {

  TranslateMessage (&msg) ;

  DispatchMessage (&msg) ;

  }

  完整代碼:

  復(fù)制代碼 代碼如下:

  #include

  LRESULT CALLBACK MyProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);

  int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd )

  {

  MSG msg;

  HWND hwnd;

  static TCHAR szAppName[] = "hl";

  WNDCLASS wndclass;

  wndclass.style = CS_HREDRAW | CS_VREDRAW;

  wndclass.cbClsExtra = 0;

  wndclass.cbWndExtra = 0;

  wndclass.lpfnWndProc = MyProc;

  wndclass.hInstance = hInstance;

  wndclass.hIcon = LoadIcon(NULL,IDI_APPLICATION);

  wndclass.hCursor = LoadCursor(NULL,IDC_ARROW);

  wndclass.hbrBackground= (HBRUSH)GetStockObject(WHITE_BRUSH);

  wndclass.lpszMenuName = NULL;

  wndclass.lpszClassName= szAppName;

  if(!RegisterClass(&wndclass))

  {

  MessageBox(NULL,TEXT("error"),TEXT("title"),MB_ICONERROR);

  return 0;

  }

  hwnd = CreateWindow(szAppName,

  TEXT("Hello"),

  WS_OVERLAPPEDWINDOW,

  CW_USEDEFAULT,

  CW_USEDEFAULT,

  CW_USEDEFAULT,

  CW_USEDEFAULT,

  NULL,

  NULL,

  hInstance,

  NULL

  );

  ShowWindow(hwnd,nShowCmd);

  UpdateWindow(hwnd);

  while(GetMessage(&msg,hwnd,0,0))

  {

  TranslateMessage(&msg);

  DispatchMessage(&msg);

  }

  return msg.wParam;

  }

  LRESULT CALLBACK MyProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)

  {

  switch(message)

  {

  case WM_DESTROY:

  PostQuitMessage(0);

  return 0;

  }

  return DefWindowProc(hwnd,message,wParam,lParam);

  }


【C語(yǔ)言創(chuàng)建windows窗口實(shí)例】相關(guān)文章:

C語(yǔ)言怎樣創(chuàng)建windows窗口03-01

C語(yǔ)言面試實(shí)例操作08-14

C語(yǔ)言自守?cái)?shù)實(shí)例04-01

C語(yǔ)言switch語(yǔ)句實(shí)例07-13

C語(yǔ)言for語(yǔ)句的用法實(shí)例07-08

C語(yǔ)言數(shù)組實(shí)例解析02-21

C語(yǔ)言親密數(shù)實(shí)例03-26

s("download_bottom");