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);
	
}
Exemple #2
0
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);

}
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_);
}
	//=============================================================================================================
	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);
	}
void CodePreview::Create(HWND parent, int width, int height)
{
	m_wndWidth = width * s_charWidth + HORIZ_MARGIN*2;
	m_wndHeight = height * s_lineHeight + VERT_MARGIN*2;
	DWORD style = WS_POPUP;
	m_hwnd = CreateWindowA(s_className, "CodePreview", style, 0, 0, m_wndWidth, m_wndHeight, parent, 0, _AtlModule.GetResourceInstance(), this);
}
	WinViewport( int W, int H, const char* Title, const char* WndClassName, WNDPROC WndProc, bool Show ) : Width( W ), Height( H )
	{
		WNDCLASS wcl;
		memset( &wcl, 0, sizeof( WNDCLASS ) );
		wcl.lpszClassName = WndClassName;
		wcl.lpfnWndProc = WndProc;
		wcl.hCursor = LoadCursor( NULL, IDC_ARROW );

		RegisterClass( &wcl );

		RECT Rect;

		Rect.left = 0;
		Rect.top = 0;
		Rect.right  = W;
		Rect.bottom = H;

		AdjustWindowRect( &Rect, WS_OVERLAPPEDWINDOW, false );

		const int WinWidth  = Rect.right  - Rect.left;
		const int WinHeight = Rect.bottom - Rect.top;

		hWnd = CreateWindowA( WndClassName, Title, WS_OVERLAPPEDWINDOW, 100, 100, WinWidth, WinHeight, 0, NULL, NULL, NULL );
		DeviceContext = GetDC( hWnd );

		if ( Show )
		{
			ShowWindow( hWnd, SW_SHOW );
			UpdateWindow( hWnd );
		}
	}
HWND
CreateTestWindow()
{
	WNDCLASSA wc;

	wc.style = 0;
	wc.lpfnWndProc = DefWindowProcA;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = g_hInstance;
	wc.hIcon = NULL;
	wc.hCursor = NULL;
	wc.hbrBackground = NULL;
	wc.lpszMenuName = NULL;
	wc.lpszClassName = "testclass";

	RegisterClassA(&wc);
	return CreateWindowA("testclass",
	                     "testwnd",
	                     WS_VISIBLE,
	                     0,
	                     0,
	                     50,
	                     30,
	                     NULL,
	                     NULL,
	                     g_hInstance,
	                     0);
}
HWND
CreateTestWindow()
{
    HINSTANCE hinst = GetModuleHandle(NULL);
	WNDCLASSA wc;

	wc.style = 0;
	wc.lpfnWndProc = DefWindowProcA;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = hinst;
	wc.hIcon = NULL;
	wc.hCursor = NULL;
	wc.hbrBackground = NULL;
	wc.lpszMenuName = NULL;
	wc.lpszClassName = "testclass";

	RegisterClassA(&wc);
	return CreateWindowA("testclass",
	                     "testwnd",
	                     WS_VISIBLE,
	                     0,
	                     0,
	                     50,
	                     30,
	                     NULL,
	                     NULL,
	                     hinst,
	                     0);
}
Exemple #9
0
static void test_gettext(void)
{
    HWND hwndStatus = CreateWindowA(SUBCLASS_NAME, NULL, WS_CHILD|WS_VISIBLE,
                                    0, 0, 300, 20, g_hMainWnd, NULL, NULL, NULL);
    char buf[5];
    int r;

    r = SendMessageA(hwndStatus, SB_SETTEXTA, 0, (LPARAM)"Text");
    expect(TRUE, r);
    r = SendMessageA(hwndStatus, WM_GETTEXTLENGTH, 0, 0);
    expect(4, r);
    /* A size of 0 returns the length of the text */
    r = SendMessageA(hwndStatus, WM_GETTEXT, 0, 0);
    ok( r == 4 || broken(r == 2) /* win8 */, "Expected 4 got %d\n", r );
    /* A size of 1 only stores the NULL terminator */
    buf[0] = 0xa;
    r = SendMessageA(hwndStatus, WM_GETTEXT, 1, (LPARAM)buf);
    ok( r == 0 || broken(r == 4), "Expected 0 got %d\n", r );
    if (!r) ok(!buf[0], "expected empty buffer\n");
    /* A size of 2 returns a length 1 */
    r = SendMessageA(hwndStatus, WM_GETTEXT, 2, (LPARAM)buf);
    ok( r == 1 || broken(r == 4), "Expected 1 got %d\n", r );
    r = SendMessageA(hwndStatus, WM_GETTEXT, sizeof(buf), (LPARAM)buf);
    expect(4, r);
    ok(!strcmp(buf, "Text"), "expected Text, got %s\n", buf);
    DestroyWindow(hwndStatus);
}
Exemple #10
0
static void mouse_tests(void)
{
    HRESULT hr;
    IDirectInputA *pDI = NULL;
    HINSTANCE hInstance = GetModuleHandleW(NULL);
    HWND hwnd;
    ULONG ref = 0;

    hr = DirectInputCreateA(hInstance, DIRECTINPUT_VERSION, &pDI, NULL);
    if (hr == DIERR_OLDDIRECTINPUTVERSION)
    {
        skip("Tests require a newer dinput version\n");
        return;
    }
    ok(SUCCEEDED(hr), "DirectInputCreateA() failed: %08x\n", hr);
    if (FAILED(hr)) return;

    hwnd = CreateWindowA("static", "Title", WS_OVERLAPPEDWINDOW, 10, 10, 200, 200, NULL, NULL,
                         NULL, NULL);
    ok(hwnd != NULL, "err: %d\n", GetLastError());
    if (hwnd)
    {
        ShowWindow(hwnd, SW_SHOW);

        test_set_coop(pDI, hwnd);
        test_acquire(pDI, hwnd);

        DestroyWindow(hwnd);
    }
    if (pDI) ref = IUnknown_Release(pDI);
    ok(!ref, "IDirectInput_Release() reference count = %d\n", ref);
}
Exemple #11
0
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;
}
Exemple #12
0
static BOOL CreateWnd(BOOL show)
{
	WNDCLASSEXA w;

	w.cbClsExtra=0;
	w.cbSize=sizeof w;
	w.cbWndExtra=0;
	w.hbrBackground=0;//GetStockObject(NULL_BRUSH);
	w.hCursor=LoadCursor(0,IDC_ARROW);
	w.hIcon=LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_ICON1));
	w.hIconSm=LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_ICON1));
	w.hInstance=GetModuleHandle(0);
	w.lpfnWndProc=&WndProc;
	w.lpszClassName=WND_CLASS_NAME;
	w.lpszMenuName=0;
	w.style=CS_HREDRAW|CS_VREDRAW;

	if(!RegisterClassExA(&w))
		return 0;

	g_hWnd=CreateWindowA(WND_CLASS_NAME,"kbswitch2",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,0,0,GetModuleHandle(0),0);
	if(!g_hWnd)
		return FALSE;

	if(show)
	{
		UpdateWindow(g_hWnd);
		ShowWindow(g_hWnd,SW_SHOW);
	}

	return TRUE;
}
Exemple #13
0
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;
}
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;
}
Exemple #15
0
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;
}
Exemple #16
0
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);
   }
}
Exemple #17
0
static void test_disableowner(void)
{
    HPROPSHEETPAGE hpsp[1];
    PROPSHEETPAGEA psp;
    PROPSHEETHEADERA psh;

    register_parent_wnd_class();
    parent = CreateWindowA("parent class", "", WS_CAPTION | WS_SYSMENU | WS_VISIBLE, 100, 100, 100, 100, GetDesktopWindow(), NULL, GetModuleHandleA(NULL), 0);

    memset(&psp, 0, sizeof(psp));
    psp.dwSize = sizeof(psp);
    psp.dwFlags = 0;
    psp.hInstance = GetModuleHandleW(NULL);
    U(psp).pszTemplate = "prop_page1";
    U2(psp).pszIcon = NULL;
    psp.pfnDlgProc = NULL;
    psp.lParam = 0;

    hpsp[0] = CreatePropertySheetPageA(&psp);

    memset(&psh, 0, sizeof(psh));
    psh.dwSize = sizeof(psh);
    psh.dwFlags = PSH_USECALLBACK;
    psh.pszCaption = "test caption";
    psh.nPages = 1;
    psh.hwndParent = parent;
    U3(psh).phpage = hpsp;
    psh.pfnCallback = disableowner_callback;

    PropertySheetA(&psh);
    ok(IsWindowEnabled(parent) != 0, "parent window should be enabled\n");
    DestroyWindow(parent);
}
	//=============================================================================================================
	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);
	}
Exemple #19
0
static HWND CreateTestWindow()
{
    MSG msg;
    WNDCLASSA  wclass;
    HANDLE hInstance = GetModuleHandleA( NULL );
    HWND hWndTest;

    wclass.lpszClassName = "MouseInputTestClass";
    wclass.style         = CS_HREDRAW | CS_VREDRAW;
    wclass.lpfnWndProc   = WndProc;
    wclass.hInstance     = hInstance;
    wclass.hIcon         = LoadIconA( 0, IDI_APPLICATION );
    wclass.hCursor       = LoadCursorA( NULL, IDC_ARROW );
    wclass.hbrBackground = (HBRUSH)( COLOR_WINDOW + 1 );
    wclass.lpszMenuName = 0;
    wclass.cbClsExtra    = 0;
    wclass.cbWndExtra    = 0;
    RegisterClassA( &wclass );
    /* create the test window that will receive the keystrokes */
    hWndTest = CreateWindowA( wclass.lpszClassName, "MouseInputTestTest",
                              WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, 100, 100,
                              NULL, NULL, hInstance, NULL);
    assert( hWndTest );
    ShowWindow( hWndTest, SW_SHOWMAXIMIZED);
    SetWindowPos( hWndTest, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE );
    SetForegroundWindow( hWndTest );
    UpdateWindow( hWndTest);
    SetFocus(hWndTest);

    /* flush pending messages */
    while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );

    return hWndTest;
}
Exemple #20
0
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);
}
Exemple #21
0
AaWindow::AaWindow(HINSTANCE hInstance, int cmdShow, int width, int heigth)
{
	this->width = width;
	this->heigth = heigth;

	WNDCLASSEX wndClass = { 0 };
	wndClass.cbSize = sizeof( WNDCLASSEX ) ;
	wndClass.style = CS_HREDRAW | CS_VREDRAW;
	wndClass.lpfnWndProc = WndProc;
	wndClass.hInstance = hInstance;
	wndClass.hCursor = LoadCursor( NULL, IDC_ARROW );
	wndClass.hbrBackground = ( HBRUSH )( COLOR_WINDOW + 1 );
	wndClass.lpszMenuName = NULL;
	wndClass.lpszClassName = "DX11BookWindowClass";
	if( !RegisterClassEx( &wndClass ) )
	return;

	RECT rc = { 0, 0, width, heigth };
	AdjustWindowRect( &rc, WS_OVERLAPPEDWINDOW, FALSE );
	hwnd = CreateWindowA( "DX11BookWindowClass", "Dx11 base engine",
	WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc.
	left,
	rc.bottom - rc.top, NULL, NULL, hInstance, NULL );
	if( !hwnd )
	return;

	ShowWindow( hwnd, cmdShow );

}
Exemple #22
0
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);
}
Exemple #23
0
// Init
//------------------------------------------------------------------------------
void OSDropDown::Init( int32_t x, int32_t y, uint32_t w, uint32_t h )
{
	#if defined( __WINDOWS__ )
		InitCommonControls();

		m_Handle = CreateWindowA( WC_COMBOBOX, 
								  "ComboBox",
								  CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_CHILD | WS_OVERLAPPED | WS_VISIBLE,
								  x, y,
								  w, h,
								  (HWND)m_Parent->GetHandle(), 
								  nullptr, 
								  nullptr, // TODO: ??? m_HInstance
								  nullptr );

		// Font
		SendMessage( (HWND)m_Handle, WM_SETFONT, (WPARAM)m_Font->GetFont(), (LPARAM)0 );
	#else
		(void)x;
		(void)y;
		(void)w;
		(void)h;
	#endif

	OSWidget::Init();
}
Exemple #24
0
static void trayicon_init(Trayicon *t)
{
	HDC hdc;
	t->hwnd = CreateWindowA(
		"STATIC", "virgo",
		0, 0, 0, 0, 0,
		NULL, NULL, NULL, NULL
	);
	t->bitmapWidth = GetSystemMetrics(SM_CXSMICON);
	t->nid.cbSize = sizeof(t->nid);
	t->nid.hWnd = t->hwnd;
	t->nid.uID = 100;
	t->nid.uFlags = NIF_ICON;
	hdc = GetDC(t->hwnd);
	t->hBitmap = CreateCompatibleBitmap(hdc, t->bitmapWidth, t->bitmapWidth);
	t->mdc = CreateCompatibleDC(hdc);
	ReleaseDC(t->hwnd, hdc);
	SetBkColor(t->mdc, RGB(0x00, 0x00, 0x00));
	SetTextColor(t->mdc, RGB(0x00, 0xFF, 0x00));
	t->hFont = CreateFont(
		-MulDiv(11, GetDeviceCaps(t->mdc, LOGPIXELSY), 72),
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TEXT("Arial")
	);
	t->nid.hIcon = trayicon_draw(t, "1", 1);
	Shell_NotifyIcon(NIM_ADD, &t->nid);
}
Exemple #25
0
static void test_messages(void)
{
    WNDCLASSA cls;
    HWND win;
    MSG msg;
    HANDLE thread;
    DWORD tid;

    InitializeCriticalSection(&clipboard_cs);

    memset(&cls, 0, sizeof(cls));
    cls.lpfnWndProc = clipboard_wnd_proc;
    cls.hInstance = GetModuleHandleA(NULL);
    cls.lpszClassName = "clipboard_test";
    RegisterClassA(&cls);

    win = CreateWindowA("clipboard_test", NULL, 0, 0, 0, 0, 0, NULL, 0, NULL, 0);
    ok(win != NULL, "CreateWindow failed: %d\n", GetLastError());

    thread = CreateThread(NULL, 0, clipboard_thread, (void*)win, 0, &tid);
    ok(thread != NULL, "CreateThread failed: %d\n", GetLastError());

    while(GetMessageA(&msg, NULL, 0, 0)) {
        TranslateMessage(&msg);
        DispatchMessageA(&msg);
    }

    ok(WaitForSingleObject(thread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
    CloseHandle(thread);

    UnregisterClassA("clipboard_test", GetModuleHandleA(NULL));
    DeleteCriticalSection(&clipboard_cs);
}
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);
}
Exemple #27
0
static HWND new_window(LPCSTR lpClassName, DWORD dwStyle, HWND parent)
{
  HWND hwnd = CreateWindowA(lpClassName, NULL,
                            dwStyle | WS_POPUP | WS_HSCROLL | WS_VSCROLL | WS_VISIBLE,
                            0, 0, 200, 60, parent, NULL, hmoduleRichEdit, NULL);
  return hwnd;
}
Exemple #28
0
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;
	}
} 
Exemple #29
0
void initWindow(const char *wndName, int x, int y, int width, int height)
{
	RECT rect;

	ACL_ASSERT(!g_hWnd,"Inited...");

	g_wndHeight = height;
	g_wndWidth = width;
	
	g_hWnd = CreateWindowA (
        g_wndClassName, wndName,
		WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX & ~WS_SIZEBOX,
		x, y, 
		width, height,
		NULL, NULL, 0, NULL) ;

    if(!g_hWnd)
    {
		MessageBoxA(NULL,"Fail to create window",g_libName,MB_ICONERROR);
        exit(0);
    }
	GetClientRect(g_hWnd,&rect);
	width += width - (rect.right-rect.left);
	height += height - (rect.bottom-rect.top);
	SetWindowPos(g_hWnd,HWND_TOP,0,0,width,height,SWP_NOMOVE);

	ShowWindow (g_hWnd,1);
	UpdateWindow (g_hWnd);
}
Exemple #30
-1
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);
}