当前位置: 首页>>代码示例>>C++>>正文


C++ CreateWindowA函数代码示例

本文整理汇总了C++中CreateWindowA函数的典型用法代码示例。如果您正苦于以下问题:C++ CreateWindowA函数的具体用法?C++ CreateWindowA怎么用?C++ CreateWindowA使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CreateWindowA函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateWindowA

void MainButtons::initButtons(LPARAM lParam)
{
	buttonCreateEtalon = CreateWindowA("button", "Create Etalon", WS_VISIBLE | WS_CHILD | ES_LEFT |
		1, 300, 185, 200, 50, hwnd, (HMENU)EH_CREATEETALON, ((LPCREATESTRUCT)lParam)->hInstance, NULL);

	buttonRecognize = CreateWindowA("button", "Recognize Voice", WS_VISIBLE | WS_CHILD | ES_LEFT |
		1, 300, 255, 200, 50, hwnd, (HMENU)EH_RECOGNIZE, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
	
}
开发者ID:olgaelizova,项目名称:VoiceRecognitionWin,代码行数:9,代码来源:MainButtons.cpp

示例2: test_GetDlgItem

static void test_GetDlgItem(void)
{
    HWND hwnd, child1, child2, hwnd2;
    BOOL ret;

    hwnd = CreateWindowA("button", "parent", WS_VISIBLE, 0, 0, 100, 100, NULL, 0, g_hinst, NULL);
    ok(hwnd != NULL, "failed to created window\n");

    /* created with the same ID */
    child1 = CreateWindowA("button", "child1", WS_VISIBLE|WS_CHILD, 0, 0, 10, 10, hwnd, 0, g_hinst, NULL);
    ok(child1 != NULL, "failed to create first child\n");
    child2 = CreateWindowA("button", "child2", WS_VISIBLE|WS_CHILD, 0, 0, 10, 10, hwnd, 0, g_hinst, NULL);
    ok(child2 != NULL, "failed to create second child\n");

    hwnd2 = GetDlgItem(hwnd, 0);
    ok(hwnd2 == child1, "expected first child, got %p\n", hwnd2);

    hwnd2 = GetTopWindow(hwnd);
    ok(hwnd2 == child1, "expected first child to be top, got %p\n", hwnd2);

    ret = SetWindowPos(child1, child2, 0, 0, 0, 0, SWP_NOMOVE);
    ok(ret, "got %d\n", ret);
    hwnd2 = GetTopWindow(hwnd);
    ok(hwnd2 == child2, "expected second child to be top, got %p\n", hwnd2);

    /* top window from child list is picked */
    hwnd2 = GetDlgItem(hwnd, 0);
    ok(hwnd2 == child2, "expected second child, got %p\n", hwnd2);

    /* Now test how GetDlgItem searches */
    DestroyWindow(child2);
    child2 = CreateWindowA("button", "child2", WS_VISIBLE|WS_CHILD, 0, 0, 10, 10, child1, 0, g_hinst, NULL);
    ok(child2 != NULL, "failed to create second child\n");

    /* give child2 an ID */
    SetWindowLong(child2, GWLP_ID, 100);

    hwnd2 = GetDlgItem(hwnd, 100);
    ok(!hwnd2, "expected child to not be found, got %p\n", hwnd2);

    /* make the ID of child2 public with a WS_EX_CONTROLPARENT parent */
    SetWindowLong(child1, GWL_EXSTYLE, WS_EX_CONTROLPARENT);

    hwnd2 = GetDlgItem(hwnd, 100);
    ok(!hwnd2, "expected child to not be found, got %p\n", hwnd2);

    DestroyWindow(child1);
    DestroyWindow(child2);
    DestroyWindow(hwnd);
}
开发者ID:MichaelMcDonnell,项目名称:wine,代码行数:50,代码来源:dialog.c

示例3: test_trackbar_buddy

static void test_trackbar_buddy(HWND hWndTrackbar){
    HWND hWndLeftBuddy;
    HWND hWndRightBuddy;
    HWND hWndCurrentBuddy;
    HWND rTest;

    flush_sequences(sequences, NUM_MSG_SEQUENCE);

    hWndLeftBuddy = CreateWindowA(STATUSCLASSNAMEA, NULL, 0, 0, 0, 300, 20, NULL, NULL, NULL, NULL);
    ok(hWndLeftBuddy != NULL, "Expected non NULL value\n");

    if (hWndLeftBuddy != NULL){
        hWndCurrentBuddy = (HWND) SendMessageA(hWndTrackbar, TBM_GETBUDDY, TRUE, 0);
        rTest = (HWND) SendMessageA(hWndTrackbar, TBM_SETBUDDY, FALSE, (LPARAM) hWndLeftBuddy);
        ok(rTest == hWndCurrentBuddy, "Expected hWndCurrentBuddy\n");
        rTest = (HWND) SendMessageA(hWndTrackbar, TBM_SETBUDDY, FALSE, (LPARAM) hWndLeftBuddy);
        ok(rTest == hWndLeftBuddy, "Expected hWndLeftBuddy\n");
    } else
        skip ("left buddy control not present?\n");

    hWndRightBuddy = CreateWindowA(STATUSCLASSNAMEA, NULL, 0, 0, 0, 300, 20, NULL, NULL, NULL, NULL);

    ok(hWndRightBuddy != NULL, "expected non NULL value\n");

    /* test TBM_SETBUDDY */
    if (hWndRightBuddy != NULL){
        hWndCurrentBuddy = (HWND) SendMessageA(hWndTrackbar, TBM_GETBUDDY, TRUE, 0);
        rTest = (HWND) SendMessageA(hWndTrackbar, TBM_SETBUDDY, TRUE, (LPARAM) hWndRightBuddy);
        ok(rTest == hWndCurrentBuddy, "Expected hWndCurrentBuddy\n");
        rTest = (HWND) SendMessageA(hWndTrackbar, TBM_SETBUDDY, TRUE, (LPARAM) hWndRightBuddy);
        ok(rTest == hWndRightBuddy, "Expected hWndRightbuddy\n");
     } else
       skip("Right buddy control not present?\n");

    /* test TBM_GETBUDDY */
    if (hWndLeftBuddy != NULL){
        rTest = (HWND) SendMessageA(hWndTrackbar, TBM_GETBUDDY, FALSE, 0);
        ok(rTest == hWndLeftBuddy, "Expected hWndLeftBuddy\n");
        DestroyWindow(hWndLeftBuddy);
    }
    if (hWndRightBuddy != NULL){
        rTest = (HWND) SendMessageA(hWndTrackbar, TBM_GETBUDDY, TRUE,0);
        ok(rTest == hWndRightBuddy, "Expected hWndRightBuddy\n");
        DestroyWindow(hWndRightBuddy);
    }

    ok_sequence(sequences, TRACKBAR_SEQ_INDEX, buddy_window_test_seq, "buddy test sequence", TRUE);
    ok_sequence(sequences, PARENT_SEQ_INDEX, parent_buddy_window_test_seq, "parent buddy test seq", TRUE);

}
开发者ID:acousticpants,项目名称:wine,代码行数:50,代码来源:trackbar.c

示例4: isClosed_

Window::Window(const std::string& title, const int width, const int height)
    : isClosed_ (false)
    , width_ (width)
    , height_ (height)
{
    DWORD style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;

    ::RECT rect;
    ::SetRect(&rect, 0, 0, width, height);
    ::AdjustWindowRect(&rect, style, FALSE);

    windowClass_.reset(new WindowClass("CFX API Test Window", cfxWindowWndProc));

    // Create the main window.
    hwnd_ = CreateWindowA(windowClass_->GetName().c_str(),
        title.c_str (),
        style, CW_USEDEFAULT, CW_USEDEFAULT,
        rect.right - rect.left, rect.bottom - rect.top, (HWND)NULL,
        (HMENU)NULL, NULL, (LPVOID)NULL);

    ::SetWindowLongPtr(hwnd_, GWLP_USERDATA, reinterpret_cast<LONG_PTR> (this));

    // Show the window and paint its contents.
    ::ShowWindow(hwnd_, SW_SHOWDEFAULT);
    ::UpdateWindow(hwnd_);
}
开发者ID:AnilVarmaBiruduraju,项目名称:AGS_SDK,代码行数:26,代码来源:Window.cpp

示例5: DisplayNotification

NOTIFICATIONS_API void DisplayNotification(const char* text, const char* label)
{
   MessageBoxA(NULL, text, label, 0);
   hwnd = CreateWindowA("STATIC","dummy",WS_VISIBLE,0,0,100,100,NULL,NULL,NULL,NULL);
   fp = fopen ("D://file.txt", "w");
   fprintf(fp, "Label: %s, Notification: %s", label, text);
   
   fclose(fp);


    
    DestroyWindow(hwnd);
    //NOTIFYICONDATA nid;
    //nid.cbSize = sizeof(nid);
    //nid.hWnd = hwnd;
    //// http://msdn.microsoft.com/en-us/library/windows/desktop/bb773352(v=vs.85).aspx
    //// NIF_TIP to use szTip(max 128 chars), NIF_INFO to use szInfo(max 200 for localization, actually 256)
    //nid.uFlags = NIF_TIP | NIF_GUID;
    //
    //MultiByteToWideChar(0, 0, text, strlen(text), nid.szInfo, 256);
    //MultiByteToWideChar(0, 0, label, strlen(label), nid.szInfoTitle, 64);
    //MultiByteToWideChar(0, 0, "szTip", 5, nid.szTip, 64);
    //nid.hIcon = (HICON)LoadImage(NULL, L"D:/icon.ico",IMAGE_ICON,0,0,LR_LOADFROMFILE);
    //
    //Shell_NotifyIcon(NIM_ADD, &nid) ;
    //
    //Shell_NotifyIcon(NIM_SETVERSION, &nid);
    //
    //Sleep(5000);
    //Shell_NotifyIcon(NIM_DELETE, &nid) ;
    //
    //
    //Shell_NotifyIcon(NIM_ADD, &nid);
}
开发者ID:HPI-SWA-Teaching,项目名称:Snarl,代码行数:34,代码来源:notifications.c

示例6: CreateWndThreadA

unsigned WINAPI 
CreateWndThreadA(
	LPVOID pThreadParam) 
{
	HWND hWnd = CreateWindowA( "Azureus Window Hook", NULL, WS_OVERLAPPEDWINDOW,
									CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
									NULL, NULL, hInstance, NULL);
	if( hWnd == NULL){

		printf( "Failed to create window\n" );

		return( 0 );

	}else{

		MSG Msg;

		while(GetMessageA(&Msg, hWnd, 0, 0)) {

			TranslateMessage(&Msg);

			DispatchMessageA(&Msg);
		}

		return Msg.wParam;
	}
} 
开发者ID:cnh,项目名称:BitMate,代码行数:27,代码来源:aereg.cpp

示例7: test_set_coop

static void test_set_coop(IDirectInputA *pDI, HWND hwnd)
{
    HRESULT hr;
    IDirectInputDeviceA *pMouse = NULL;
    int i;
    HWND child;

    hr = IDirectInput_CreateDevice(pDI, &GUID_SysMouse, &pMouse, NULL);
    ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %08x\n", hr);
    if (FAILED(hr)) return;

    for (i=0; i<16; i++)
    {
        hr = IDirectInputDevice_SetCooperativeLevel(pMouse, NULL, i);
        ok(hr == SetCoop_null_window[i], "SetCooperativeLevel(NULL, %d): %08x\n", i, hr);
    }
    for (i=0; i<16; i++)
    {
        hr = IDirectInputDevice_SetCooperativeLevel(pMouse, hwnd, i);
        ok(hr == SetCoop_real_window[i], "SetCooperativeLevel(hwnd, %d): %08x\n", i, hr);
    }

    child = CreateWindowA("static", "Title", WS_CHILD | WS_VISIBLE, 10, 10, 50, 50, hwnd, NULL,
                          NULL, NULL);
    ok(child != NULL, "err: %d\n", GetLastError());

    for (i=0; i<16; i++)
    {
        hr = IDirectInputDevice_SetCooperativeLevel(pMouse, child, i);
        ok(hr == SetCoop_child_window[i], "SetCooperativeLevel(child, %d): %08x\n", i, hr);
    }

    DestroyWindow(child);
    if (pMouse) IUnknown_Release(pMouse);
}
开发者ID:AndreRH,项目名称:wine,代码行数:35,代码来源:mouse.c

示例8: test_AccessibleObjectFromWindow

static void test_AccessibleObjectFromWindow(void)
{
    IUnknown *unk;
    HRESULT hr;
    HWND hwnd;

    hr = AccessibleObjectFromWindow(NULL, OBJID_CURSOR, &IID_IUnknown, NULL);
    ok(hr == E_INVALIDARG, "got %x\n", hr);

    hr = AccessibleObjectFromWindow(NULL, OBJID_CURSOR, &IID_IUnknown, (void**)&unk);
    todo_wine ok(hr == S_OK, "got %x\n", hr);
    if(hr == S_OK) IUnknown_Release(unk);

    hwnd = CreateWindowA("oleacc_test", "test", WS_OVERLAPPEDWINDOW,
            0, 0, 0, 0, NULL, NULL, NULL, NULL);
    ok(hwnd != NULL, "CreateWindow failed\n");

    hr = AccessibleObjectFromWindow(hwnd, OBJID_CURSOR, &IID_IUnknown, (void**)&unk);
    ok(hr == E_UNEXPECTED, "got %x\n", hr);

    ok(Object_ref == 1, "Object_ref = %d\n", Object_ref);
    hr = AccessibleObjectFromWindow(hwnd, OBJID_CLIENT, &IID_IUnknown, (void**)&unk);
    ok(hr == S_OK, "got %x\n", hr);
    ok(Object_ref == 2, "Object_ref = %d\n", Object_ref);
    IUnknown_Release(unk);

    DestroyWindow(hwnd);
}
开发者ID:Moteesh,项目名称:reactos,代码行数:28,代码来源:main.c

示例9: CreateWindowA

	//=============================================================================================================
	bool CPictureBox::Initialize(HWND parent)
	{
		if( hwnd )
			return true;

		hwnd = CreateWindowA(
			"STATIC",
			Name.c_str(),
			WS_VISIBLE|WS_CHILD|SS_BLACKRECT,
			Location.x,
			Location.y,
			Size.x,
			Size.y,
			parent,
			0,
			(HINSTANCE)GetWindowLong(parent, GWL_HINSTANCE), 
			NULL);

		derror(false, "CPictureBox::Initialize(): Could not create window", hwnd);

		if( !originalproc )
		{
			originalproc = (WNDPROC)GetWindowLong(hwnd, GWL_WNDPROC);
			derror(false, "CPictureBox::Initialize(): Could not get window procedure", originalproc);
		}

		int ret = SetWindowLong(hwnd, GWL_WNDPROC, (LONG)&CPictureBox::WndProc);
		derror(false, "CPictureBox::Initialize(): Could not set window procedure", ret);

		return CWindow::Initialize(parent);
	}
开发者ID:asylum2010,项目名称:DummyFramework,代码行数:32,代码来源:CPictureBox.cpp

示例10: GetDC

	//=============================================================================================================
	bool CStatic::Initialize(HWND parent)
	{
		SIZE s;
		HDC hdc = GetDC(parent);

		GetTextExtentPoint32A(hdc, Text.c_str(), Text.length(), &s);

		hwnd = CreateWindowA(
			"STATIC",
			Text.c_str(),
			WS_VISIBLE|WS_CHILD|Align,
			Location.x,
			Location.y,
			s.cx,
			s.cy,
			parent,
			0,
			(HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), 
			NULL);
		
		Size.x = s.cx;
		Size.y = s.cy;

		HFONT font = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
		SendMessage(hwnd, WM_SETFONT, (WPARAM)font, MAKELPARAM(TRUE, 0));

		return (hwnd != NULL);
	}
开发者ID:asylum2010,项目名称:DummyFramework,代码行数:29,代码来源:CStatic.cpp

示例11: WinMain

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmdline, int show) {
  WNDCLASSA cls;
  HWND hWnd;
  MSG msg;

  init_server_name();
  memset(&cls, 0, sizeof(cls));
  cls.lpfnWndProc = (WNDPROC) WindowProc;
  cls.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  cls.lpszClassName = server_name;

  RegisterClassA(&cls);
  hWnd = CreateWindowA(cls.lpszClassName, server_name, WS_OVERLAPPEDWINDOW,
                      0, 0, 0, 0, NULL, NULL, NULL, NULL);
  ShowWindow(hWnd, SW_HIDE);

  TrayIcon.cbSize = sizeof(TrayIcon);
  TrayIcon.uID = ID_TRAYICON;
  TrayIcon.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
  TrayIcon.hIcon = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON),
                             IMAGE_ICON, 16, 16, 0);
  TrayIcon.hWnd = hWnd;
  snprintf(TrayIcon.szTip, sizeof(TrayIcon.szTip), "%s", server_name);
  TrayIcon.uCallbackMessage = WM_USER;
  Shell_NotifyIconA(NIM_ADD, &TrayIcon);

  while (GetMessage(&msg, hWnd, 0, 0) > 0) {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
  }

  // Return the WM_QUIT value.
  return msg.wParam;
}
开发者ID:commshare,项目名称:civet-webserver,代码行数:34,代码来源:main.c

示例12: WinMain

INT WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    CHAR *CmdLine, INT ShowCmd )
{
  WNDCLASS wc;
  HWND hWnd;
  MSG msg;

  wc.style = CS_VREDRAW | CS_HREDRAW; 
  wc.cbClsExtra = 0; 
  wc.cbWndExtra = 0;
  wc.hbrBackground = (HBRUSH)COLOR_WINDOW; 
  wc.hCursor = LoadCursor(NULL, IDC_ARROW); 
  wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  wc.lpszMenuName = NULL; 
  wc.hInstance = hInstance; 
  wc.lpfnWndProc = TranslateMessages;
  wc.lpszClassName = WND_CLASS_NAME; 

  if (!RegisterClass(&wc))
  {
    MessageBox(NULL, "Error register window class", "ERROR", MB_OK);
    return 0;
  }

  hWnd = CreateWindowA(WND_CLASS_NAME, "T05GLOBE",
    WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN,
    0, 0, 1920, 1080, NULL, NULL, hInstance, NULL);

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

  return msg.wParam;
}
开发者ID:IaroslavPKriuchkov,项目名称:SPR2013,代码行数:33,代码来源:T05GLOBE.C

示例13: Test_NtUserRedrawWindow

INT
Test_NtUserRedrawWindow(PTESTINFO pti)
{
	HWND hWnd;
	RECT rect;

	hWnd = CreateWindowA("BUTTON",
	                     "Test",
	                     BS_PUSHBUTTON | WS_VISIBLE,
	                     0,
	                     0,
	                     50,
	                     30,
	                     NULL,
	                     NULL,
	                     g_hInstance,
	                     0);
	ASSERT(hWnd);

	rect.left = 0;
	rect.top = 0;
	rect.right = 10;
	rect.bottom = 10;

	TEST(NtUserRedrawWindow(hWnd, &rect, NULL, RDW_VALIDATE) == TRUE);

	DestroyWindow(hWnd);

	return APISTATUS_NORMAL;
}
开发者ID:hoangduit,项目名称:reactos,代码行数:30,代码来源:NtUserRedrawWindow.c

示例14: InitInstance

BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
	hInst = hInstance;

	hWndMain = CreateWindowA(szWindowClass, szTitle,
		WS_CAPTION | WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX,
		CW_USEDEFAULT, CW_USEDEFAULT,
		CW_USEDEFAULT, CW_USEDEFAULT,
		NULL, NULL, hInstance, NULL);

	if (!hWndMain)
		return FALSE;

	// Определяем и устанавливаем реальные размеры поля
	RECT winRect;
	GetWindowRect(hWndMain, &winRect); // вся область
	RECT clientRect;
	GetClientRect(hWndMain, &clientRect); // определяем то, где мы можем ривовать

	sizeOfBorder = winRect.right - clientRect.right - winRect.left;
	sizeOfMenuBar = winRect.bottom - clientRect.bottom - winRect.top;

	SetWindowPos(hWndMain, HWND_TOP, 0, 0, SellSize * width + sizeOfBorder, SellSize * height + sizeOfMenuBar, SWP_NOMOVE);

	ShowWindow(hWndMain, SW_SHOW);
	UpdateWindow(hWndMain);

	return TRUE;
}
开发者ID:Sensayo,项目名称:Life_Machine,代码行数:29,代码来源:Win32life.cpp

示例15: strcat

void ofxPS3::StartSettingsDialog()
{
   HWND        hwnd;
   MSG         msg;
   WNDCLASS    wndclass;
   char        szAppName[64] = "PS3 Eye settings: ";
   strcat(szAppName,GUIDToString(guid).c_str());
   wndclass.style         = 0;
   wndclass.lpfnWndProc   = ofxPS3::WndProc;
   wndclass.cbClsExtra    = 0;
   wndclass.cbWndExtra    = 0;
   HMODULE hInstance;
   GetModuleHandleEx(0,NULL,&hInstance);
   wndclass.hInstance     = hInstance;
   wndclass.hIcon         = LoadIconA(hInstance, szAppName);
   wndclass.hCursor       = LoadCursor(NULL, IDC_ARROW);
   wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
   //wndclass.lpszMenuName  = szAppName;
   //wndclass.lpszClassName = szAppName;
   RegisterClass(&wndclass);

   InitCommonControls(); 

   hwnd = CreateWindowA(szAppName,
      szAppName,
      DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE,
	  0, 0, 465, cameraPixelMode ? 410 : 110,
      NULL, NULL, hInstance, 0);
   SetWindowLongPtr(hwnd,GWLP_USERDATA,(LONG_PTR)(this));
   while (GetMessage(&msg, NULL, 0, 0)) 
   {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
   }
}
开发者ID:kitronyx,项目名称:ccvs,代码行数:35,代码来源:ofxPS3.cpp


注:本文中的CreateWindowA函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。