Beispiel #1
0
/* MAKE_EXPORT LoadIconW_new=LoadIconW */
HICON WINAPI LoadIconW_new(HINSTANCE hInstance, LPCWSTR lpIconNameW)
{
	if(IS_INTRESOURCE(lpIconNameW))
		return LoadIconA(hInstance, (LPCSTR)lpIconNameW);

	ALLOC_WtoA(lpIconName);

	return LoadIconA(hInstance, lpIconNameA);
}
Beispiel #2
0
static void test_cbsize(void)
{
    NOTIFYICONDATAA nidA;
    BOOL ret;

    if (pShell_NotifyIconW)
    {
        NOTIFYICONDATAW nidW;

        ZeroMemory(&nidW, sizeof(nidW));
        nidW.cbSize = NOTIFYICONDATAW_V1_SIZE;
        nidW.hWnd = hMainWnd;
        nidW.uID = 1;
        nidW.uFlags = NIF_ICON|NIF_MESSAGE;
        nidW.hIcon = LoadIconA(NULL, (LPSTR)IDI_APPLICATION);
        nidW.uCallbackMessage = WM_USER+17;
        ret = pShell_NotifyIconW(NIM_ADD, &nidW);
        ok(ret, "NIM_ADD failed!\n");
        /* using an invalid cbSize does work */
        nidW.cbSize = 3;
        nidW.hWnd = hMainWnd;
        nidW.uID = 1;
        ret = pShell_NotifyIconW(NIM_DELETE, &nidW);
        ok( ret || broken(!ret), /* nt4 */ "NIM_DELETE failed!\n");
        /* as icon doesn't exist anymore - now there will be an error */
        nidW.cbSize = sizeof(nidW);
        ok(!pShell_NotifyIconW(NIM_DELETE, &nidW) != !ret, "The icon was not deleted\n");
    }

    /* same for Shell_NotifyIconA */
    ZeroMemory(&nidA, sizeof(nidA));
    nidA.cbSize = NOTIFYICONDATAA_V1_SIZE;
    nidA.hWnd = hMainWnd;
    nidA.uID = 1;
    nidA.uFlags = NIF_ICON|NIF_MESSAGE;
    nidA.hIcon = LoadIconA(NULL, (LPSTR)IDI_APPLICATION);
    nidA.uCallbackMessage = WM_USER+17;
    ok(Shell_NotifyIconA(NIM_ADD, &nidA), "NIM_ADD failed!\n");

    /* using an invalid cbSize does work */
    nidA.cbSize = 3;
    nidA.hWnd = hMainWnd;
    nidA.uID = 1;
    ret = Shell_NotifyIconA(NIM_DELETE, &nidA);
    ok(ret, "NIM_DELETE failed!\n");
    /* as icon doesn't exist anymore - now there will be an error */
    nidA.cbSize = sizeof(nidA);
    ok(!Shell_NotifyIconA(NIM_DELETE, &nidA) != !ret, "The icon was not deleted\n");
}
Beispiel #3
0
/*************************************************************************
 *				ExtractAssociatedIcon	[SHELL.36]
 *
 * Return icon for given file (either from file itself or from associated
 * executable) and patch parameters if needed.
 */
HICON16 WINAPI ExtractAssociatedIcon16(HINSTANCE16 hInst, LPSTR lpIconPath, LPWORD lpiIcon)
{	HICON16 hIcon;
	WORD wDummyIcon = 0;

	TRACE("\n");

	if(lpiIcon == NULL)
	    lpiIcon = &wDummyIcon;

	hIcon = ExtractIcon16(hInst, lpIconPath, *lpiIcon);

	if( hIcon < 2 )
	{ if( hIcon == 1 ) /* no icons found in given file */
	  { char  tempPath[0x80];
	    UINT16  uRet = FindExecutable16(lpIconPath,NULL,tempPath);

	    if( uRet > 32 && tempPath[0] )
	    { strcpy(lpIconPath,tempPath);
	      hIcon = ExtractIcon16(hInst, lpIconPath, *lpiIcon);
	      if( hIcon > 2 )
	        return hIcon;
	    }
	    else hIcon = 0;
	  }

	  if( hIcon == 1 )
	    *lpiIcon = 2;   /* MSDOS icon - we found .exe but no icons in it */
	  else
	    *lpiIcon = 6;   /* generic icon - found nothing */

	  GetModuleFileName16(hInst, lpIconPath, 0x80);
	  hIcon = LoadIconA( hInst, MAKEINTRESOURCEA(*lpiIcon));
	}
	return hIcon;
}
Beispiel #4
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;
}
Beispiel #5
0
static void createwindow(void)
{
    wc.style = CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc = DefWindowProcA;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hInstance = GetModuleHandleA(0);
    wc.hIcon = LoadIconA(wc.hInstance, IDI_APPLICATION);
    wc.hCursor = LoadCursorA(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
    wc.lpszMenuName = NULL;
    wc.lpszClassName = "TestWindowClass";
    if(!RegisterClassA(&wc))
        assert(0);
    
    hwnd = CreateWindowExA(0, "TestWindowClass", "TestWindowClass",
        WS_POPUP, 0, 0,
        GetSystemMetrics(SM_CXSCREEN),
        GetSystemMetrics(SM_CYSCREEN),
        NULL, NULL, GetModuleHandleA(0), NULL);
    assert(hwnd != NULL);
    
    ShowWindow(hwnd, SW_HIDE);
    UpdateWindow(hwnd);
    SetFocus(hwnd);
    
}
Beispiel #6
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);
   }
}
Beispiel #7
0
HICON GetConnectingIconForProto_DLL(char *szProto,int b)
{
	char szFullPath[MAX_PATH];
	HICON hIcon=NULL;

	b=b-1;
	_snprintf(szFullPath, SIZEOF(szFullPath), "proto_conn_%s.dll",szProto);
	//		hIcon=ExtractIconFromPath(szFullPath);
	//		if (hIcon) return hIcon;

	hIcon=LoadIconFromExternalFile(szFullPath,b+1,FALSE,FALSE,NULL,NULL,NULL,0,0);
	if (hIcon) return hIcon;

#ifdef _DEBUG
	{
		char buf [256];
		sprintf(buf,"IconNotFound %s %d\r\n",szProto,b);
		//	OutputDebugStringA(buf);
	}
#endif

	if (!strcmp(szProto,"ICQ"))
	{

#ifdef _DEBUG
		char buf [256];
		sprintf(buf,"Icon %d %d\r\n",GetTickCount(),b);
		//OutputDebugStringA(buf);
#endif
		return(LoadIconA(g_hInst,(LPCSTR)(IDI_ICQC1+b)));
	}

	return(hIcon);
}
Beispiel #8
0
/**
 * sgens_window_show(): Show the VDP Layer Options window.
 * @param parent Parent window.
 */
void MDP_FNCALL sgens_window_show(void *parent)
{
	if (sgens_window)
	{
		// Sonic Gens window is already visible. Set focus.
		// TODO: Figure out how to do this.
		ShowWindow(sgens_window, SW_SHOW);
		return;
	}
	
	// Initialize the Win32 Unicode Translation Layer.
	w32u_init();
	
	sgens_window_child_windows_created = FALSE;
	
	// If no HINSTANCE was specified, use the main executable's HINSTANCE.
	if (!sgens_hInstance)
		sgens_hInstance = GetModuleHandle(NULL);
	
	if (sgens_wndclass.lpfnWndProc != sgens_window_wndproc)
	{
		// Create the window class.
		sgens_wndclass.style = 0;
		sgens_wndclass.lpfnWndProc = sgens_window_wndproc;
		sgens_wndclass.cbClsExtra = 0;
		sgens_wndclass.cbWndExtra = 0;
		sgens_wndclass.hInstance = sgens_hInstance;
		sgens_wndclass.hIcon = LoadIconA(sgens_hInstance, MAKEINTRESOURCE(IDI_SGENS));
		sgens_wndclass.hCursor = LoadCursorA(NULL, IDC_ARROW);
		sgens_wndclass.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
		sgens_wndclass.lpszMenuName = NULL;
		sgens_wndclass.lpszClassName = "mdp_misc_sgens_window";
		
		pRegisterClassU(&sgens_wndclass);
	}
	
	// Create the window.
	sgens_window = pCreateWindowU("mdp_misc_sgens_window", "Sonic Gens",
					WS_DLGFRAME | WS_POPUP | WS_SYSMENU | WS_CAPTION,
					CW_USEDEFAULT, CW_USEDEFAULT,
					SGENS_WINDOW_WIDTH, SGENS_WINDOW_HEIGHT,
					(HWND)parent, NULL, sgens_hInstance, NULL);
	
	// Window adjustment.
	gsft_win32_set_actual_window_size(sgens_window, SGENS_WINDOW_WIDTH, SGENS_WINDOW_HEIGHT);
	gsft_win32_center_on_window(sgens_window, (HWND)parent);
	
	// Update the current ROM type and information display.
	sgens_window_update_rom_type();
	sgens_window_update();
	
	UpdateWindow(sgens_window);
	ShowWindow(sgens_window, TRUE);
	
	// Register the window with MDP Host Services.
	sgens_host_srv->window_register(&mdp, sgens_window);
}
Beispiel #9
0
/**
 * vlopt_window_show(): Show the VDP Layer Options window.
 * @param parent Parent window.
 */
void vlopt_window_show(void *parent)
{
	if (vlopt_window)
	{
		// VDP Layer Options window is already visible.
		// Set focus.
		// TODO
		return;
	}
	
	// Initialize the Win32 Unicode Translation Layer.
	w32u_init();
	
	vlopt_window_child_windows_created = FALSE;
	
	// If no HINSTANCE was specified, use the main executable's HINSTANCE.
	if (!vlopt_hInstance)
		vlopt_hInstance = pGetModuleHandleU(NULL);
	
	// Create the window class.
	if (vlopt_window_wndclass.lpfnWndProc != vlopt_window_wndproc)
	{
		vlopt_window_wndclass.style = 0;
		vlopt_window_wndclass.lpfnWndProc = vlopt_window_wndproc;
		vlopt_window_wndclass.cbClsExtra = 0;
		vlopt_window_wndclass.cbWndExtra = 0;
		vlopt_window_wndclass.hInstance = vlopt_hInstance;
		vlopt_window_wndclass.hIcon = LoadIconA(vlopt_hInstance, MAKEINTRESOURCE(IDI_VLOPT));
		vlopt_window_wndclass.hCursor = LoadCursorA(NULL, IDC_ARROW);
		vlopt_window_wndclass.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
		vlopt_window_wndclass.lpszMenuName = NULL;
		vlopt_window_wndclass.lpszClassName = "vlopt_window_wndclass";
		
		pRegisterClassU(&vlopt_window_wndclass);
	}
	
	// Create the window.
	vlopt_window = pCreateWindowU("vlopt_window_wndclass", "VDP Layer Options",
					WS_DLGFRAME | WS_POPUP | WS_SYSMENU | WS_CAPTION,
					CW_USEDEFAULT, CW_USEDEFAULT,
					DLU_X(VLOPT_WINDOW_WIDTH), DLU_Y(VLOPT_WINDOW_HEIGHT),
					(HWND)parent, NULL, vlopt_hInstance, NULL);
	
	// Window adjustment.
	gsft_win32_set_actual_window_size(vlopt_window, DLU_X(VLOPT_WINDOW_WIDTH), DLU_Y(VLOPT_WINDOW_HEIGHT));
	gsft_win32_center_on_window(vlopt_window, (HWND)parent);
	
	UpdateWindow(vlopt_window);
	ShowWindow(vlopt_window, TRUE);
	
	// Register the window with MDP Host Services.
	vlopt_host_srv->window_register(&mdp, vlopt_window);
}
ATOM RegisterWinClass(const char* pszName,
					  WNDPROC proc,
					  HINSTANCE hInst,
					  UINT menuID,
					  UINT iconID,
					  UINT smallIconID)
{
	WNDCLASSEXA wc = {};
	wc.cbSize = sizeof(wc);

	wc.style		= CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc	= proc;
	wc.lpszClassName = pszName;
	wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
	wc.hCursor		= LoadCursor(NULL, IDC_ARROW);
	wc.hInstance	= hInst;
	wc.lpszMenuName	= MAKEINTRESOURCEA(menuID);
	wc.hIcon		= LoadIconA(hInst, MAKEINTRESOURCEA(iconID));
	wc.hIconSm		= LoadIconA(hInst, MAKEINTRESOURCEA(smallIconID));
	return RegisterClassExA(&wc);
}
void FsOpenWindow(int x0,int y0,int wid,int hei,int useDoubleBuffer)
{
	// Note 2012/03/08 RegisterClassW and CreateWindowW doesn't seem to work.
	WNDCLASSA wc;
	HINSTANCE inst=GetModuleHandleA(NULL);

	wc.style=CS_OWNDC|CS_BYTEALIGNWINDOW;
	wc.lpfnWndProc=(WNDPROC)WindowFunc;
	wc.cbClsExtra=0;
	wc.cbWndExtra=0;
	wc.hInstance=(HINSTANCE)inst;
	wc.hIcon=LoadIconA(inst,"MAINICON");
	wc.hCursor=LoadCursor(NULL,IDC_ARROW);
	wc.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
	wc.lpszMenuName=NULL;
	wc.lpszClassName=WINCLASS;
	if(0!=RegisterClassA(&wc))
	{
		doubleBuffer=useDoubleBuffer;


		RECT rc;
		rc.left  =x0;
		rc.top   =y0;
		rc.right =(unsigned long)(x0+wid-1);
		rc.bottom=(unsigned long)(y0+hei-1);
		AdjustWindowRect(&rc,WINSTYLE,FALSE);
		wid  =rc.right-rc.left+1;
		hei  =rc.bottom-rc.top+1;

		fsWin32Internal.hWnd=CreateWindowA(WINCLASS,WINNAME,WINSTYLE,x0,y0,wid,hei,NULL,NULL,inst,NULL);
		if(NULL!=fsWin32Internal.hWnd)
		{
			InitializeOpenGL(fsWin32Internal.hWnd);

			ShowWindow(fsWin32Internal.hWnd,SW_SHOWNORMAL);
			UpdateWindow(fsWin32Internal.hWnd);
		}
		else
		{
			printf("Could not open window.\n");
			exit(1);
		}
	}
}
Beispiel #12
0
	KBOOL AppFrame::Initialize( KCCHAR* pTitle, KCCHAR* pIcon )
	{
		if (g_theApp) return false;
		else  g_theApp = this;

#ifdef _DEBUG
		m_pRoot = OGRE_NEW Ogre::Root("plugins_debug.cfg");
#else
		m_pRoot = OGRE_NEW Ogre::Root();
#endif

		//////////////////////////////////////////////////////////////////////////
		if(m_pRoot->restoreConfig() || m_pRoot->showConfigDialog())
		{
			m_pWindow = m_pRoot->initialise(true, pTitle);
			
			//-------------------------------------------------------
			// ╪стьм╪╠Й
			HWND hwnd;
			m_pWindow->getCustomAttribute("WINDOW", (void*)&hwnd);

			HINSTANCE hinstance;
			hinstance = GetModuleHandle(NULL);
			HICON icon = LoadIconA(hinstance, pIcon);

			SendMessage(hwnd, WM_SETICON, ICON_BIG, LPARAM(icon));
			SendMessage(hwnd, WM_SETICON, ICON_SMALL, LPARAM(icon));
			//-------------------------------------------------------

			if (!LoadResources())
				return false;

			// Set default mipmap level (NB some APIs ignore this)
			Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
			
			Ogre::WindowEventUtilities::addWindowEventListener(m_pWindow, this);
			m_pRoot->addFrameListener(this);

			//////////////////////////////////////////////////////////////////////////
			CreateWidgets();
			
			return true;
		}
		
		return false;
Beispiel #13
0
/******************************************************************************
 * OleMetaFilePictFromIconAndLabel (OLE2.56)
 *
 * Returns a global memory handle to a metafile which contains the icon and
 * label given.
 * I guess the result of that should look somehow like desktop icons.
 * If no hIcon is given, we load the icon via lpszSourceFile and iIconIndex.
 * This code might be wrong at some places.
 */
HGLOBAL16 WINAPI OleMetaFilePictFromIconAndLabel16(
	HICON16 hIcon,
	LPCOLESTR16 lpszLabel,
	LPCOLESTR16 lpszSourceFile,
	UINT16 iIconIndex
) {
    METAFILEPICT16 *mf16;
    HGLOBAL16 hmf16;
    HMETAFILE hmf;
    INT mfSize;
    HDC hdc;

    if (!hIcon) {
        if (lpszSourceFile) {
	    HINSTANCE16 hInstance = LoadLibrary16(lpszSourceFile);

	    /* load the icon at index from lpszSourceFile */
	    hIcon = HICON_16(LoadIconA(HINSTANCE_32(hInstance), (LPCSTR)(DWORD)iIconIndex));
	    FreeLibrary16(hInstance);
	} else
	    return 0;
    }

    FIXME("(%04x, '%s', '%s', %d): incorrect metrics, please try to correct them !\n", 
          hIcon, lpszLabel, lpszSourceFile, iIconIndex);

    hdc = CreateMetaFileW(NULL);
    DrawIcon(hdc, 0, 0, HICON_32(hIcon)); /* FIXME */
    TextOutA(hdc, 0, 0, lpszLabel, 1); /* FIXME */
    hmf = CloseMetaFile(hdc);

    hmf16 = GlobalAlloc16(0, sizeof(METAFILEPICT16));
    mf16 = (METAFILEPICT16 *)GlobalLock16(hmf16);
    mf16->mm = MM_ANISOTROPIC;
    mf16->xExt = 20; /* FIXME: bogus */
    mf16->yExt = 20; /* dito */
    mfSize = GetMetaFileBitsEx(hmf, 0, 0);
    mf16->hMF = GlobalAlloc16(GMEM_MOVEABLE, mfSize);
    if(mf16->hMF)
    {
        GetMetaFileBitsEx(hmf, mfSize, GlobalLock16(mf16->hMF));
        GlobalUnlock16(mf16->hMF);
    }
    return hmf16;
}
/**
* Similar to LoadIconW() Win32 Base API (user32.dll),
* except that it will work also on Win9x/ME without MSLU support.
*/
UAWIN32API  HICON
WINAPI      ULoadIcon(
    HINSTANCE   hInstance,
    LPCWSTR     lpcwszFileName) /*UTF-16 IN*/
{
    static BOOL bDisable_LoadIconW = FALSE;
    if (!bDisable_LoadIconW &&
        isWin32UnicodeAPIsSupported()) {
        typedef HICON
            (WINAPI *FARPROC_LoadIconW)(
            HINSTANCE   hInstance,
            LPCWSTR     lpIconName);    /*UTF-16 IN*/
        static FARPROC_LoadIconW farproc_LoadIconW =
            (FARPROC_LoadIconW)NULL;

        if (farproc_LoadIconW == (FARPROC_LoadIconW)NULL) {
            HMODULE hModule = GetModuleHandleA("user32.dll");
            farproc_LoadIconW = (FARPROC_LoadIconW)
                GetProcAddress(hModule, "LoadIconW");
        }
        if (farproc_LoadIconW != (FARPROC_LoadIconW)NULL) {
            return (*farproc_LoadIconW)(
                hInstance,
                lpcwszFileName);    /*UTF-16 IN*/
        }
        bDisable_LoadIconW = TRUE;
    }
    /* Convert UTF-16 input strings to ANSI */
    LPCWSTR_TO_LPSTR(lpcwszFileName,
        return (HICON)1
        );
    /* Execute the ANSI API */
    return LoadIconA(
        hInstance,
        (LPCSTR)lpcwszFileName);    /*ANSI IN*/
}
Beispiel #15
0
/***********************************************************************
 *           PRINTDLG_WMInitDialog                      [internal]
 */
static LRESULT PRINTDLG_WMInitDialog16(HWND hDlg, WPARAM wParam, PRINT_PTRA16* ptr16)
{
    PRINT_PTRA *PrintStructures = &ptr16->print32;
    LPPRINTDLG16 lppd = ptr16->lpPrintDlg16;
    DEVNAMES *pdn;
    DEVMODEA *pdm;
    char *name = NULL;
    UINT comboID = (lppd->Flags & PD_PRINTSETUP) ? cmb1 : cmb4;

    /* load Collate ICONs */
    PrintStructures->hCollateIcon =
        LoadIconA(COMDLG32_hInstance, "PD32_COLLATE");
    PrintStructures->hNoCollateIcon =
        LoadIconA(COMDLG32_hInstance, "PD32_NOCOLLATE");
    if(PrintStructures->hCollateIcon == 0 ||
            PrintStructures->hNoCollateIcon == 0) {
        ERR("no icon in resourcefile\n");
        COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
        EndDialog(hDlg, FALSE);
    }

    /* load Paper Orientation ICON */
    /* FIXME: not implemented yet */

    /*
     * if lppd->Flags PD_SHOWHELP is specified, a HELPMESGSTRING message
     * must be registered and the Help button must be shown.
     */
    if (lppd->Flags & PD_SHOWHELP) {
        if((PrintStructures->HelpMessageID =
                    RegisterWindowMessageA(HELPMSGSTRINGA)) == 0) {
            COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);
            return FALSE;
        }
    } else
        PrintStructures->HelpMessageID = 0;

    if (!(lppd->Flags & PD_PRINTSETUP)) {
        /* We have a print quality combo box. What shall we do? */
        if (GetDlgItem(hDlg,cmb1)) {
            char buf [20];

            FIXME("Print quality only displaying currently.\n");

            pdm = GlobalLock16(lppd->hDevMode);
            if(pdm) {
                switch (pdm->u1.s1.dmPrintQuality) {
                case DMRES_HIGH		:
                    strcpy(buf,"High");
                    break;
                case DMRES_MEDIUM	:
                    strcpy(buf,"Medium");
                    break;
                case DMRES_LOW		:
                    strcpy(buf,"Low");
                    break;
                case DMRES_DRAFT	:
                    strcpy(buf,"Draft");
                    break;
                case 0			:
                    strcpy(buf,"Default");
                    break;
                default			:
                    sprintf(buf,"%ddpi",pdm->u1.s1.dmPrintQuality);
                    break;
                }
                GlobalUnlock16(lppd->hDevMode);
            } else
                strcpy(buf,"Default");
            SendDlgItemMessageA(hDlg,cmb1,CB_ADDSTRING,0,(LPARAM)buf);
            SendDlgItemMessageA(hDlg,cmb1,CB_SETCURSEL,0,0);
            EnableWindow(GetDlgItem(hDlg,cmb1),FALSE);
        }
    }

    /* FIXME: I allow more freedom than either Win95 or WinNT,
     *        which do not agree to what errors should be thrown or not
     *        in case nToPage or nFromPage is out-of-range.
     */
    if (lppd->nMaxPage < lppd->nMinPage)
        lppd->nMaxPage = lppd->nMinPage;
    if (lppd->nMinPage == lppd->nMaxPage)
        lppd->Flags |= PD_NOPAGENUMS;
    if (lppd->nToPage < lppd->nMinPage)
        lppd->nToPage = lppd->nMinPage;
    if (lppd->nToPage > lppd->nMaxPage)
        lppd->nToPage = lppd->nMaxPage;
    if (lppd->nFromPage < lppd->nMinPage)
        lppd->nFromPage = lppd->nMinPage;
    if (lppd->nFromPage > lppd->nMaxPage)
        lppd->nFromPage = lppd->nMaxPage;

    /* If the printer combo box is in the dialog, fill it */
    if (GetDlgItem(hDlg,comboID)) {
        /* Fill Combobox
         */
        pdn = GlobalLock16(lppd->hDevNames);
        pdm = GlobalLock16(lppd->hDevMode);
        if(pdn)
            name = (char*)pdn + pdn->wDeviceOffset;
        else if(pdm)
            name = (char*)pdm->dmDeviceName;
        PRINTDLG_SetUpPrinterListComboA(hDlg, comboID, name);
        if(pdm) GlobalUnlock16(lppd->hDevMode);
        if(pdn) GlobalUnlock16(lppd->hDevNames);

        /* Now find selected printer and update rest of dlg */
        name = HeapAlloc(GetProcessHeap(),0,256);
        if (GetDlgItemTextA(hDlg, comboID, name, 255))
            PRINTDLG_ChangePrinterA(hDlg, name, PrintStructures);
    } else {
        /* else just use default printer */
        char name[200];
        DWORD dwBufLen = sizeof(name);
        BOOL ret = GetDefaultPrinterA(name, &dwBufLen);

        if (ret)
            PRINTDLG_ChangePrinterA(hDlg, name, PrintStructures);
        else
            FIXME("No default printer found, expect problems!\n");
    }
    HeapFree(GetProcessHeap(),0,name);

    return TRUE;
}
Beispiel #16
0
static void test_status_control(void)
{
    HWND hWndStatus;
    int r;
    int nParts[] = {50, 150, -1};
    int checkParts[] = {0, 0, 0};
    int borders[] = {0, 0, 0};
    RECT rc;
    CHAR charArray[20];
    HICON hIcon;
    char ch;
    char chstr[10] = "Inval id";
    COLORREF crColor = RGB(0,0,0);

    hWndStatus = create_status_control(WS_VISIBLE | SBT_TOOLTIPS, 0);

    /* Divide into parts and set text */
    r = SendMessageA(hWndStatus, SB_SETPARTS, 3, (LPARAM)nParts);
    expect(TRUE,r);
    r = SendMessageA(hWndStatus, SB_SETTEXTA, SBT_POPOUT|0,    (LPARAM)"First");
    expect(TRUE,r);
    r = SendMessageA(hWndStatus, SB_SETTEXTA, SBT_OWNERDRAW|1, (LPARAM)"Second");
    expect(TRUE,r);
    r = SendMessageA(hWndStatus, SB_SETTEXTA, SBT_NOBORDERS|2, (LPARAM)"Third");
    expect(TRUE,r);

    /* Get RECT Information */
    r = SendMessageA(hWndStatus, SB_GETRECT, 0, (LPARAM)&rc);
    expect(TRUE,r);
    expect(2,rc.top);
    /* The rc.bottom test is system dependent
    expect(22,rc.bottom); */
    expect(0,rc.left);
    expect(50,rc.right);
    r = SendMessageA(hWndStatus, SB_GETRECT, -1, (LPARAM)&rc);
    expect(FALSE,r);
    r = SendMessageA(hWndStatus, SB_GETRECT, 3, (LPARAM)&rc);
    expect(FALSE,r);
    /* Get text length and text */
    r = SendMessageA(hWndStatus, SB_GETTEXTLENGTHA, 0, 0);
    expect(5,LOWORD(r));
    expect(SBT_POPOUT,HIWORD(r));
    r = SendMessageW(hWndStatus, WM_GETTEXTLENGTH, 0, 0);
    ok(r == 5 || broken(0x02000005 /* NT4 */), "Expected 5, got %d\n", r);
    r = SendMessageA(hWndStatus, SB_GETTEXTLENGTHA, 1, 0);
    expect(0,LOWORD(r));
    expect(SBT_OWNERDRAW,HIWORD(r));
    r = SendMessageA(hWndStatus, SB_GETTEXTLENGTHA, 2, 0);
    expect(5,LOWORD(r));
    expect(SBT_NOBORDERS,HIWORD(r));
    r = SendMessageA(hWndStatus, SB_GETTEXTA, 2, (LPARAM) charArray);
    ok(strcmp(charArray,"Third") == 0, "Expected Third, got %s\n", charArray);
    expect(5,LOWORD(r));
    expect(SBT_NOBORDERS,HIWORD(r));

    /* Get parts and borders */
    r = SendMessageA(hWndStatus, SB_GETPARTS, 3, (LPARAM)checkParts);
    ok(r == 3, "Expected 3, got %d\n", r);
    expect(50,checkParts[0]);
    expect(150,checkParts[1]);
    expect(-1,checkParts[2]);
    r = SendMessageA(hWndStatus, SB_GETBORDERS, 0, (LPARAM)borders);
    ok(r == TRUE, "Expected TRUE, got %d\n", r);
    expect(0,borders[0]);
    expect(2,borders[1]);
    expect(2,borders[2]);

    /* Test resetting text with different characters */
    r = SendMessageA(hWndStatus, SB_SETTEXTA, 0, (LPARAM)"First@Again");
    expect(TRUE,r);
    r = SendMessageA(hWndStatus, SB_SETTEXTA, 1, (LPARAM)"Invalid\tChars\\7\7");
    expect(TRUE,r);
    r = SendMessageA(hWndStatus, SB_SETTEXTA, 2, (LPARAM)"InvalidChars\\n\n");
    expect(TRUE,r);

    /* Get text again */
    r = SendMessageA(hWndStatus, SB_GETTEXTA, 0, (LPARAM) charArray);
    ok(strcmp(charArray,"First@Again") == 0, "Expected First@Again, got %s\n", charArray);
    expect(11,LOWORD(r));
    expect(0,HIWORD(r));
    r = SendMessageA(hWndStatus, SB_GETTEXTA, 1, (LPARAM) charArray);
    ok(strcmp(charArray,"Invalid\tChars\\7 ") == 0, "Expected Invalid\tChars\\7 , got %s\n", charArray);

    expect(16,LOWORD(r));
    expect(0,HIWORD(r));
    r = SendMessageA(hWndStatus, SB_GETTEXTA, 2, (LPARAM) charArray);
    ok(strcmp(charArray,"InvalidChars\\n ") == 0, "Expected InvalidChars\\n , got %s\n", charArray);

    expect(15,LOWORD(r));
    expect(0,HIWORD(r));

    /* test more nonprintable chars */
    for(ch = 0x00; ch < 0x7F; ch++) {
        chstr[5] = ch;
        r = SendMessageA(hWndStatus, SB_SETTEXTA, 0, (LPARAM)chstr);
        expect(TRUE,r);
        r = SendMessageA(hWndStatus, SB_GETTEXTA, 0, (LPARAM)charArray);
        /* substitution with single space */
        if (ch > 0x00 && ch < 0x20 && ch != '\t')
            chstr[5] = ' ';
        ok(strcmp(charArray, chstr) == 0, "Expected %s, got %s\n", chstr, charArray);
    }

    /* Set background color */
    crColor = SendMessageA(hWndStatus, SB_SETBKCOLOR , 0, RGB(255,0,0));
    ok(crColor == CLR_DEFAULT ||
       broken(crColor == RGB(0,0,0)), /* win95 */
       "Expected 0x%.8x, got 0x%.8x\n", CLR_DEFAULT, crColor);
    crColor = SendMessageA(hWndStatus, SB_SETBKCOLOR , 0, CLR_DEFAULT);
    ok(crColor == RGB(255,0,0) ||
       broken(crColor == RGB(0,0,0)), /* win95 */
       "Expected 0x%.8x, got 0x%.8x\n", RGB(255,0,0), crColor);

    /* Add an icon to the status bar */
    hIcon = LoadIconA(NULL, (LPCSTR)IDI_QUESTION);
    r = SendMessageA(hWndStatus, SB_SETICON, 1, 0);
    ok(r != 0 ||
       broken(r == 0), /* win95 */
       "Expected non-zero, got %d\n", r);
    r = SendMessageA(hWndStatus, SB_SETICON, 1, (LPARAM) hIcon);
    ok(r != 0 ||
       broken(r == 0), /* win95 */
       "Expected non-zero, got %d\n", r);
    r = SendMessageA(hWndStatus, SB_SETICON, 1, 0);
    ok(r != 0 ||
       broken(r == 0), /* win95 */
       "Expected non-zero, got %d\n", r);

    /* Set the Unicode format */
    r = SendMessageA(hWndStatus, SB_SETUNICODEFORMAT, FALSE, 0);
    expect(FALSE,r);
    r = SendMessageA(hWndStatus, SB_GETUNICODEFORMAT, 0, 0);
    expect(FALSE,r);
    r = SendMessageA(hWndStatus, SB_SETUNICODEFORMAT, TRUE, 0);
    expect(FALSE,r);
    r = SendMessageA(hWndStatus, SB_GETUNICODEFORMAT, 0, 0);
    ok(r == TRUE ||
       broken(r == FALSE), /* win95 */
       "Expected TRUE, got %d\n", r);

    /* Reset number of parts */
    r = SendMessageA(hWndStatus, SB_SETPARTS, 2, (LPARAM)nParts);
    expect(TRUE,r);
    r = SendMessageA(hWndStatus, SB_GETPARTS, 0, 0);
    ok(r == 2, "Expected 2, got %d\n", r);
    r = SendMessageA(hWndStatus, SB_SETPARTS, 0, 0);
    expect(FALSE,r);
    r = SendMessageA(hWndStatus, SB_GETPARTS, 0, 0);
    ok(r == 2, "Expected 2, got %d\n", r);

    /* Set the minimum height and get rectangle information again */
    SendMessageA(hWndStatus, SB_SETMINHEIGHT, 50, 0);
    r = SendMessageA(hWndStatus, WM_SIZE, 0, 0);
    expect(0,r);
    r = SendMessageA(hWndStatus, SB_GETRECT, 0, (LPARAM)&rc);
    expect(TRUE,r);
    expect(2,rc.top);
    /* The rc.bottom test is system dependent
    expect(22,rc.bottom); */
    expect(0,rc.left);
    expect(50,rc.right);
    r = SendMessageA(hWndStatus, SB_GETRECT, -1, (LPARAM)&rc);
    expect(FALSE,r);
    r = SendMessageA(hWndStatus, SB_GETRECT, 3, (LPARAM)&rc);
    expect(FALSE,r);

    /* Set the ToolTip text */
    SendMessageA(hWndStatus, SB_SETTIPTEXTA, 0,(LPARAM) "Tooltip Text");
    lstrcpyA(charArray, "apple");
    SendMessageA(hWndStatus, SB_GETTIPTEXTA, MAKEWPARAM (0, 20),(LPARAM) charArray);
    ok(strcmp(charArray,"Tooltip Text") == 0 ||
       broken(!strcmp(charArray, "apple")), /* win95 */
       "Expected Tooltip Text, got %s\n", charArray);

    /* Make simple */
    SendMessageA(hWndStatus, SB_SIMPLE, TRUE, 0);
    r = SendMessageA(hWndStatus, SB_ISSIMPLE, 0, 0);
    ok(r == TRUE ||
       broken(r == FALSE), /* win95 */
       "Expected TRUE, got %d\n", r);

    DestroyWindow(hWndStatus);
}
Beispiel #17
0
static BOOL wined3d_dll_init(HINSTANCE hInstDLL)
{
    DWORD wined3d_context_tls_idx;
    HMODULE mod;
    char buffer[MAX_PATH+10];
    DWORD size = sizeof(buffer);
    HKEY hkey = 0;
    HKEY appkey = 0;
    DWORD len, tmpvalue;
    WNDCLASSA wc;

    wined3d_context_tls_idx = TlsAlloc();
    if (wined3d_context_tls_idx == TLS_OUT_OF_INDEXES)
    {
        DWORD err = GetLastError();
        ERR("Failed to allocate context TLS index, err %#x.\n", err);
        return FALSE;
    }
    context_set_tls_idx(wined3d_context_tls_idx);

    /* We need our own window class for a fake window which we use to retrieve GL capabilities */
    /* We might need CS_OWNDC in the future if we notice strange things on Windows.
     * Various articles/posts about OpenGL problems on Windows recommend this. */
    wc.style                = CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc          = DefWindowProcA;
    wc.cbClsExtra           = 0;
    wc.cbWndExtra           = 0;
    wc.hInstance            = hInstDLL;
    wc.hIcon                = LoadIconA(NULL, (LPCSTR)IDI_WINLOGO);
    wc.hCursor              = LoadCursorA(NULL, (LPCSTR)IDC_ARROW);
    wc.hbrBackground        = NULL;
    wc.lpszMenuName         = NULL;
    wc.lpszClassName        = WINED3D_OPENGL_WINDOW_CLASS_NAME;

    if (!RegisterClassA(&wc))
    {
        ERR("Failed to register window class 'WineD3D_OpenGL'!\n");
        if (!TlsFree(wined3d_context_tls_idx))
        {
            DWORD err = GetLastError();
            ERR("Failed to free context TLS index, err %#x.\n", err);
        }
        return FALSE;
    }

    DisableThreadLibraryCalls(hInstDLL);

    mod = GetModuleHandleA( "winex11.drv" );
    if (mod)
    {
        wine_tsx11_lock_ptr   = (void *)GetProcAddress( mod, "wine_tsx11_lock" );
        wine_tsx11_unlock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_unlock" );
    }
    else /* We are most likely on Windows */
    {
        wine_tsx11_lock_ptr   = wined3d_do_nothing;
        wine_tsx11_unlock_ptr = wined3d_do_nothing;
    }
    /* @@ Wine registry key: HKCU\Software\Wine\Direct3D */
    if ( RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Direct3D", &hkey ) ) hkey = 0;

    len = GetModuleFileNameA( 0, buffer, MAX_PATH );
    if (len && len < MAX_PATH)
    {
        HKEY tmpkey;
        /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\Direct3D */
        if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\AppDefaults", &tmpkey ))
        {
            char *p, *appname = buffer;
            if ((p = strrchr( appname, '/' ))) appname = p + 1;
            if ((p = strrchr( appname, '\\' ))) appname = p + 1;
            strcat( appname, "\\Direct3D" );
            TRACE("appname = [%s]\n", appname);
            if (RegOpenKeyA( tmpkey, appname, &appkey )) appkey = 0;
            RegCloseKey( tmpkey );
        }
    }

    if (hkey || appkey)
    {
        if ( !get_config_key( hkey, appkey, "VertexShaderMode", buffer, size) )
        {
            if (!strcmp(buffer,"none"))
            {
                TRACE("Disable vertex shaders\n");
                wined3d_settings.vs_mode = VS_NONE;
            }
        }
        if ( !get_config_key( hkey, appkey, "PixelShaderMode", buffer, size) )
        {
            if (!strcmp(buffer,"enabled"))
            {
                TRACE("Allow pixel shaders\n");
                wined3d_settings.ps_mode = PS_HW;
            }
            if (!strcmp(buffer,"disabled"))
            {
                TRACE("Disable pixel shaders\n");
                wined3d_settings.ps_mode = PS_NONE;
            }
        }
        if ( !get_config_key( hkey, appkey, "UseGLSL", buffer, size) )
        {
            if (!strcmp(buffer,"disabled"))
            {
                ERR_(winediag)("The GLSL shader backend has been disabled. You get to keep all the pieces if it breaks.\n");
                TRACE("Use of GL Shading Language disabled\n");
                wined3d_settings.glslRequested = FALSE;
            }
        }
        if ( !get_config_key( hkey, appkey, "OffscreenRenderingMode", buffer, size) )
        {
            if (!strcmp(buffer,"backbuffer"))
            {
                TRACE("Using the backbuffer for offscreen rendering\n");
                wined3d_settings.offscreen_rendering_mode = ORM_BACKBUFFER;
            }
            else if (!strcmp(buffer,"fbo"))
            {
                TRACE("Using FBOs for offscreen rendering\n");
                wined3d_settings.offscreen_rendering_mode = ORM_FBO;
            }
        }
        if ( !get_config_key( hkey, appkey, "RenderTargetLockMode", buffer, size) )
        {
            if (!strcmp(buffer,"readdraw"))
            {
                TRACE("Using glReadPixels for render target reading and glDrawPixels for writing\n");
                wined3d_settings.rendertargetlock_mode = RTL_READDRAW;
            }
            else if (!strcmp(buffer,"readtex"))
            {
                TRACE("Using glReadPixels for render target reading and textures for writing\n");
                wined3d_settings.rendertargetlock_mode = RTL_READTEX;
            }
        }
        if ( !get_config_key_dword( hkey, appkey, "VideoPciDeviceID", &tmpvalue) )
        {
            int pci_device_id = tmpvalue;

            /* A pci device id is 16-bit */
            if(pci_device_id > 0xffff)
            {
                ERR("Invalid value for VideoPciDeviceID. The value should be smaller or equal to 65535 or 0xffff\n");
            }
            else
            {
                TRACE("Using PCI Device ID %04x\n", pci_device_id);
                wined3d_settings.pci_device_id = pci_device_id;
            }
        }
        if ( !get_config_key_dword( hkey, appkey, "VideoPciVendorID", &tmpvalue) )
        {
            int pci_vendor_id = tmpvalue;

            /* A pci device id is 16-bit */
            if(pci_vendor_id > 0xffff)
            {
                ERR("Invalid value for VideoPciVendorID. The value should be smaller or equal to 65535 or 0xffff\n");
            }
            else
            {
                TRACE("Using PCI Vendor ID %04x\n", pci_vendor_id);
                wined3d_settings.pci_vendor_id = pci_vendor_id;
            }
        }
        if ( !get_config_key( hkey, appkey, "VideoMemorySize", buffer, size) )
        {
            int TmpVideoMemorySize = atoi(buffer);
            if(TmpVideoMemorySize > 0)
            {
                wined3d_settings.emulated_textureram = TmpVideoMemorySize *1024*1024;
                TRACE("Use %iMB = %d byte for emulated_textureram\n",
                        TmpVideoMemorySize,
                        wined3d_settings.emulated_textureram);
            }
            else
                ERR("VideoMemorySize is %i but must be >0\n", TmpVideoMemorySize);
        }
        if ( !get_config_key( hkey, appkey, "WineLogo", buffer, size) )
        {
            size_t len = strlen(buffer) + 1;

            wined3d_settings.logo = HeapAlloc(GetProcessHeap(), 0, len);
            if (!wined3d_settings.logo) ERR("Failed to allocate logo path memory.\n");
            else memcpy(wined3d_settings.logo, buffer, len);
        }
        if ( !get_config_key( hkey, appkey, "Multisampling", buffer, size) )
        {
            if (!strcmp(buffer, "disabled"))
            {
                TRACE("Multisampling disabled.\n");
                wined3d_settings.allow_multisampling = FALSE;
            }
        }
        if (!get_config_key(hkey, appkey, "StrictDrawOrdering", buffer, size)
                && !strcmp(buffer,"enabled"))
        {
            TRACE("Enforcing strict draw ordering.\n");
            wined3d_settings.strict_draw_ordering = TRUE;
        }
        if (!get_config_key(hkey, appkey, "AlwaysOffscreen", buffer, size)
                && !strcmp(buffer,"enabled"))
        {
            TRACE("Always rendering backbuffers offscreen.\n");
            wined3d_settings.always_offscreen = TRUE;
        }
    }
    if (wined3d_settings.vs_mode == VS_HW)
        TRACE("Allow HW vertex shaders\n");
    if (wined3d_settings.ps_mode == PS_NONE)
        TRACE("Disable pixel shaders\n");
    if (wined3d_settings.glslRequested)
        TRACE("If supported by your system, GL Shading Language will be used\n");

    if (appkey) RegCloseKey( appkey );
    if (hkey) RegCloseKey( hkey );

    return TRUE;
}
Beispiel #18
0
/*
=======================================
    WinMain 程序入口
=======================================
*/
int WINAPI
WinMain (
  __CR_IN__ HINSTANCE   curt_app,
  __CR_IN__ HINSTANCE   prev_app,
  __CR_IN__ LPSTR       cmd_line,
  __CR_IN__ int         cmd_show
    )
{
    uint_t      argc;
    ansi_t**    argv;

    CR_NOUSE(prev_app);
    CR_NOUSE(cmd_show);

    /* 只允许一个例程 */
    if (misc_is_running(EXE_XNAME))
        return (QST_ERROR);

    /* 建立 CrHack 系统 */
    if (!set_app_type(CR_APP_GUI))
        return (QST_ERROR);
    mem_zero(&s_wrk_ctx, sizeof(s_wrk_ctx));

    int qt_argc;

    /* 获取命令行参数, 不包括进程文件名 */
    argv = misc_get_param(cmd_line, &argc);
    qt_argc = (int)argc;

    QApplication    qt_app(qt_argc, argv);

    qt_app.setApplicationName("QstComm");
    qt_app.setOrganizationName("QuestLAB");

    sint_t  x1, y1;
    uint_t  ww, hh;

    /* 生成一个可变大小的窗口 */
    mtlock_init(&s_wrk_ctx.lock);
    qst_load_cfg(&s_wrk_ctx.cfgs);
    misc_desk_init(WIN_ICONF, &x1, &y1, &ww, &hh,
                   QCOM_DEF_WIDTH, QCOM_DEF_HEIGHT);
    if (ww < QCOM_DEF_WIDTH)  ww = QCOM_DEF_WIDTH;
    if (hh < QCOM_DEF_HEIGHT) hh = QCOM_DEF_HEIGHT;

    RECT            w_rect;
    sint_t          fw, fh;
    QMainWindow     qt_win;

    /* Qt 里的宽高都不包括边框
       需要自己用 Win32 API 获取 */
    qt_win.setWindowFlags(qt_win.windowFlags()
        & (~Qt::WindowMaximizeButtonHint));
    qt_win.move(x1, y1);
    qt_win.resize(ww, hh);
    s_wrk_ctx.hwnd = (HWND)qt_win.winId();
    if (!GetWindowRect(s_wrk_ctx.hwnd, &w_rect))
        return (QST_ERROR);
    fw = w_rect.right - w_rect.left - ww;
    fh = w_rect.bottom - w_rect.top - hh;
    qt_win.setMinimumSize(QCOM_DEF_WIDTH  - fw,
                          QCOM_DEF_HEIGHT - fh);
    qt_win.resize(ww - fw, hh - fh);

    QWidget*        cent = new QWidget (&qt_win);
    CTextEdit*      edit = new CTextEdit (cent);
    QHBoxLayout*    hori = new QHBoxLayout (cent);

    /* 创建窗体里的控件 */
    hori->setSpacing(6);
    hori->setContentsMargins(8, 8, 8, 8);
    hori->addWidget(edit);
    qt_win.setCentralWidget(cent);

    CTextOper   oper(&qt_win, edit);

    s_wrk_ctx.oper = (void_t*)(&oper);
    SetClassLongPtr(s_wrk_ctx.hwnd, GCLP_HICON, (LONG_PTR)
                    LoadIconA(curt_app, (ansi_t*)101));

    /* 初始化 ANSI 上下文 */
    if (!qst_csi_init())
        return (QST_ERROR);
    qst_set_viewer(&s_wrk_ctx);

    /* 初始化网络 */
    if (!socket_init())
        return (QST_ERROR);
    s_wrk_ctx.netw = netw_cli_open(EXE_XNAME);
    if (s_wrk_ctx.netw == NULL)
        return (QST_ERROR);

    /* 读取需要超时, 不然线程无法退出 */
    socket_set_timeout(s_wrk_ctx.netw, -1, QST_TCP_TOUT);

    thrd_t  thrd;

    /* 生成工作线程 */
    s_wrk_ctx.quit = FALSE;
    s_wrk_ctx.comm.quit = FALSE;
    s_wrk_ctx.comm.text = TRUE;
    s_wrk_ctx.comm.rtype = "text";
    s_wrk_ctx.comm.stype = "text";
    s_wrk_ctx.comm.title = NULL;
    s_wrk_ctx.comm.render = qst_txt_show;
    s_wrk_ctx.page = get_sys_codepage();
    qst_update_title(&s_wrk_ctx);
    thrd = thread_new(0, qst_com_main, &s_wrk_ctx, FALSE);
    if (thrd == NULL)
        return (QST_ERROR);
    sio_init();

    /* 开始 Qt 流程 */
    qt_win.show();
    qt_app.exec();

    /* 关闭线程直接退出 */
    if (!s_wrk_ctx.quit)
        s_wrk_ctx.quit = TRUE;
    thread_wait(thrd);
    thread_del(thrd);
    netw_cli_close(s_wrk_ctx.netw);
    sio_free();
    qst_csi_free();
    return (QST_OKAY);
}
  Window::Window(Engine *aEngine, const char *aWindowName,
                 const char *aWindowIcon, const char *aCursorIcon, int aWidth,
                 int aHeight, Window *aParentWindow)
    : mEngine(aEngine), mParentWindow(aParentWindow), mHeight(aHeight), mWidth(aWidth)
  {
    WindowData *windowData = mPlatformSpecificData.ConstructAndGet<WindowData>();

    WNDCLASS windowsData;

    if (aWindowName == nullptr)
    {
      aWindowName = "Yours-Truly-Engine";
    }

    if (nullptr == aWindowIcon)
    {
      aWindowIcon = IDI_APPLICATION;
    }

    if (nullptr == aCursorIcon)
    {
      aCursorIcon = IDC_ARROW;
    }

    HWND parentHandle = nullptr;
    if (nullptr != aParentWindow)
    {
      parentHandle = aParentWindow->mPlatformSpecificData.Get<WindowData>()->mWindowHandle;
    }

    windowsData.style = CS_HREDRAW | CS_VREDRAW;

    //TODO: Investigate the following flags
    //mData.mWindowsData.style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;

    // Set our message pump callback.
    windowsData.lpfnWndProc = WindowsMessagePump;
    windowsData.cbClsExtra = 0;
    windowsData.cbWndExtra = 0;

    // This needs to be changed for multiple windows to work, I think.
    windowData->mInstance = GetModuleHandleA(nullptr);
    windowsData.hInstance = windowData->mInstance;

    windowsData.hIcon = LoadIconA(nullptr, aWindowIcon);

    windowsData.hCursor = LoadCursorA(nullptr, aCursorIcon);

    windowsData.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
    windowsData.lpszMenuName = aWindowName;
    windowsData.lpszClassName = "Yours-Truly-Engine_Game";

    RegisterClass(&windowsData);

    windowData->mWindowHandle = CreateWindowExA(
                                                0,
                                                windowsData.lpszClassName,
                                                windowsData.lpszMenuName,
                                                WS_OVERLAPPEDWINDOW,
                                                CW_USEDEFAULT,
                                                CW_USEDEFAULT,
                                                aWidth,
                                                aHeight,
                                                parentHandle,
                                                nullptr,
                                                windowsData.hInstance,
                                                this
                                               );

    // The window was sized to the values we want for the client area.
    // Add the difference between the two to grow the client area correctly,
    // unless the windows border size changes based on window size or 
    // something but thats weird so I'm not going to deal with that.
    RECT clientSize;
    GetClientRect(windowData->mWindowHandle, &clientSize);

    // Keep the previous position (more or less)
    RECT forPosition;
    GetWindowRect(windowData->mWindowHandle, &forPosition);
    int differenceX = aWidth - clientSize.right;
    int differenceY = aHeight - clientSize.bottom;

    // Try to keep the window centered by assuming the border is spaced
    // evenly (almost certainly wrong on the Y axis if it has a window title)
    MoveWindow(
               windowData->mWindowHandle, 
               forPosition.left - differenceX / 2,
               forPosition.top - differenceY / 2, 
               aWidth + differenceX,
               aHeight + differenceY, 
               false
              );

    ShowWindow(windowData->mWindowHandle, SW_SHOWNORMAL);
    UpdateWindow(windowData->mWindowHandle);
  }
Beispiel #20
0
BOOL CALLBACK SetupDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  static HICON hPluginIcon;
  static HWND hWndCaptureTitle;
  static HWND hWndSeparator;
  static HWND hWndPasteSerialTitle;
  static HWND hWndHotkeyDelimSkip;
  static HWND hWndHotkeyDelimAsTab;
  static HWND hWndHotkeyDelimAsIs;

  if (uMsg == WM_INITDIALOG)
  {
    //Load plugin icon
    hPluginIcon=LoadIconA(hInstanceDLL, MAKEINTRESOURCEA(IDI_ICON_PLUGIN));
    SendMessage(hDlg, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)hPluginIcon);

    hWndCaptureTitle=GetDlgItem(hDlg, IDC_SETUP_CAPTURE_TITLE);
    hWndSeparator=GetDlgItem(hDlg, IDC_SETUP_CAPTURE_SEPARATOR);
    hWndPasteSerialTitle=GetDlgItem(hDlg, IDC_SETUP_PASTESERIAL_TITLE);
    hWndHotkeyDelimSkip=GetDlgItem(hDlg, IDC_SETUP_PASTESERIAL_DELIMSKIP);
    hWndHotkeyDelimAsTab=GetDlgItem(hDlg, IDC_SETUP_PASTESERIAL_DELIMASTAB);
    hWndHotkeyDelimAsIs=GetDlgItem(hDlg, IDC_SETUP_PASTESERIAL_DELIMASIS);

    SetWindowTextWide(hDlg, wszPluginTitle);
    SetDlgItemTextWide(hDlg, IDC_SETUP_CAPTURE_SEPARATOR_LABEL, GetLangStringW(wLangModule, STRID_SEPARATOR));
    SetDlgItemTextWide(hDlg, IDC_SETUP_CAPTURE_SEPARATOR_LEGEND, GetLangStringW(wLangModule, STRID_LEGEND));
    SetDlgItemTextWide(hDlg, IDC_SETUP_PASTESERIAL_GROUP, GetLangStringW(wLangModule, STRID_GLOBALHOTKEYS));
    SetDlgItemTextWide(hDlg, IDC_SETUP_PASTESERIAL_DELIMSKIP_LABEL, GetLangStringW(wLangModule, STRID_DELIMSKIP));
    SetDlgItemTextWide(hDlg, IDC_SETUP_PASTESERIAL_DELIMASTAB_LABEL, GetLangStringW(wLangModule, STRID_DELIMASTAB));
    SetDlgItemTextWide(hDlg, IDC_SETUP_PASTESERIAL_DELIMASIS_LABEL, GetLangStringW(wLangModule, STRID_DELIMASIS));
    SetDlgItemTextWide(hDlg, IDOK, GetLangStringW(wLangModule, STRID_OK));
    SetDlgItemTextWide(hDlg, IDCANCEL, GetLangStringW(wLangModule, STRID_CANCEL));

    if (!bInitCapture) EnableWindow(hWndCaptureTitle, FALSE);
    if (!bInitPasteSerial) EnableWindow(hWndPasteSerialTitle, FALSE);
    SendMessage(hWndSeparator, EM_LIMITTEXT, MAX_PATH, 0);
    EscapeDataToEscapeString(wszCaptureSeparator, wszBuffer);
    SetWindowTextWide(hWndSeparator, wszBuffer);

    SendMessage(hWndHotkeyDelimSkip, HKM_SETHOTKEY, dwHotkeyDelimSkip, 0);
    SendMessage(hWndHotkeyDelimAsTab, HKM_SETHOTKEY, dwHotkeyDelimAsTab, 0);
    SendMessage(hWndHotkeyDelimAsIs, HKM_SETHOTKEY, dwHotkeyDelimAsIs, 0);
  }
  else if (uMsg == WM_COMMAND)
  {
    if (LOWORD(wParam) == IDOK)
    {
      GetWindowTextWide(hWndSeparator, wszBuffer, MAX_PATH);
      EscapeStringToEscapeData(wszBuffer, wszCaptureSeparator);

      dwHotkeyDelimSkip=(DWORD)SendMessage(hWndHotkeyDelimSkip, HKM_GETHOTKEY, 0, 0);
      dwHotkeyDelimAsTab=(DWORD)SendMessage(hWndHotkeyDelimAsTab, HKM_GETHOTKEY, 0, 0);
      dwHotkeyDelimAsIs=(DWORD)SendMessage(hWndHotkeyDelimAsIs, HKM_GETHOTKEY, 0, 0);

      if (nInitMain)
      {
        if (bInitCapture)
        {
          UninitCapture();
          InitCapture();
        }
        if (bInitPasteSerial)
        {
          UninitPasteSerial();
          InitPasteSerial();
        }
        if (bInitSelAutoCopy)
        {
          UninitSelAutoCopy();
          InitSelAutoCopy();
        }
      }
      dwSaveFlags|=OF_CAPTURE_SETTINGS|OF_PASTESERIAL_SETTINGS;

      if (dwSaveFlags)
      {
        SaveOptions(dwSaveFlags);
        dwSaveFlags=0;
      }

      EndDialog(hDlg, 0);
      return TRUE;
    }
    else if (LOWORD(wParam) == IDCANCEL)
    {
      EndDialog(hDlg, 0);
      return TRUE;
    }
  }
  else if (uMsg == WM_CLOSE)
  {
    PostMessage(hDlg, WM_COMMAND, IDCANCEL, 0);
    return TRUE;
  }
  else if (uMsg == WM_DESTROY)
  {
    //Destroy plugin icon
    DestroyIcon(hPluginIcon);
  }
  return FALSE;
}
Beispiel #21
0
VOID OnInitDialog(HWND hwnd)
{
    int i, n;
    double e;
    char buf[64], *p;
    HICON hIcon;

    // set big icon
    hIcon = LoadIconA(GetModuleHandleA(NULL), MAKEINTRESOURCEA(1));
    SendMessageA(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
    // set small icon
    hIcon = (HICON)LoadImageA(GetModuleHandleA(NULL), MAKEINTRESOURCEA(1),
        IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
    SendMessageA(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
    // set window title
    SetWindowText(hwnd, progname);

    for (i = 0; i < hack_argcount; i++)
    {
        SetDlgItemTextA(hwnd, IDC_ARGNAME00 + i, hack_arginfo[i].name);

        switch (hack_arginfo[i].type)
        {
        case t_Bool:
            if (*(Bool *)hack_arginfo[i].data)
                SetDlgItemTextA(hwnd, IDC_ARGVAL00 + i, "True");
            else
                SetDlgItemTextA(hwnd, IDC_ARGVAL00 + i, "False");
            break;

        case t_Int:
            n = *(INT *)hack_arginfo[i].data;
            SetDlgItemInt(hwnd, IDC_ARGVAL00 + i, n, TRUE);
            break;

        case t_Float:
            e = *(float *)hack_arginfo[i].data;
            sprintf(buf, "%g", e);
            SetDlgItemTextA(hwnd, IDC_ARGVAL00 + i, buf);
            break;

        case t_String:
            p = *(char **)hack_arginfo[i].data;
            SetDlgItemTextA(hwnd, IDC_ARGVAL00 + i, p);
            break;
        }
    }

    for (; i <= 23; i++)
    {
        ShowWindow(GetDlgItem(hwnd, IDC_ARGNAME00 + i), SW_HIDE);
        ShowWindow(GetDlgItem(hwnd, IDC_ARGVAL00 + i), SW_HIDE);
    }

    if (hack_count_enabled)
    {
        n = ss.modeinfo.count;
        SetDlgItemInt(hwnd, IDC_COUNTVAL, n, TRUE);
    }
    else
    {
        ShowWindow(GetDlgItem(hwnd, IDC_COUNTNAME), SW_HIDE);
        ShowWindow(GetDlgItem(hwnd, IDC_COUNTVAL), SW_HIDE);
    }

    if (hack_cycles_enabled)
    {
        n = ss.modeinfo.cycles;
        SetDlgItemInt(hwnd, IDC_CYCLESVAL, n, TRUE);
    }
    else
    {
        ShowWindow(GetDlgItem(hwnd, IDC_CYCLESNAME), SW_HIDE);
        ShowWindow(GetDlgItem(hwnd, IDC_CYCLESVAL), SW_HIDE);
    }

    if (hack_size_enabled)
    {
        n = ss.modeinfo.size;
        SetDlgItemInt(hwnd, IDC_SIZEVAL, n, TRUE);
    }
    else
    {
        ShowWindow(GetDlgItem(hwnd, IDC_SIZENAME), SW_HIDE);
        ShowWindow(GetDlgItem(hwnd, IDC_SIZEVAL), SW_HIDE);
    }

    CenterDialog(hwnd);
}
Beispiel #22
0
void winopen()
{
	WNDCLASS wc;
	HMENU menu;
	RECT r;
	ATOM a;

	/* Create and register window frame class */
	memset(&wc, 0, sizeof(wc));
	wc.style = 0;
	wc.lpfnWndProc = frameproc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = GetModuleHandle(NULL);
	wc.hIcon = LoadIconA(wc.hInstance, "IDI_ICONAPP");
	wc.hCursor = NULL; //LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = NULL;
	wc.lpszMenuName = NULL;
	wc.lpszClassName = L"FrameWindow";
	a = RegisterClassW(&wc);
	if (!a)
		winerror(&gapp, "cannot register frame window class");

	/* Create and register window view class */
	memset(&wc, 0, sizeof(wc));
	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc = viewproc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = GetModuleHandle(NULL);
	wc.hIcon = NULL;
	wc.hCursor = NULL;
	wc.hbrBackground = NULL;
	wc.lpszMenuName = NULL;
	wc.lpszClassName = L"ViewWindow";
	a = RegisterClassW(&wc);
	if (!a)
		winerror(&gapp, "cannot register view window class");

	/* Get screen size */
	SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0);
	gapp.scrw = r.right - r.left;
	gapp.scrh = r.bottom - r.top;

	/* Create cursors */
	arrowcurs = LoadCursor(NULL, IDC_ARROW);
	handcurs = LoadCursor(NULL, IDC_HAND);
	waitcurs = LoadCursor(NULL, IDC_WAIT);
	caretcurs = LoadCursor(NULL, IDC_IBEAM);

	/* And a background color */
	bgbrush = CreateSolidBrush(RGB(0x70,0x70,0x70));
	shbrush = CreateSolidBrush(RGB(0x40,0x40,0x40));

	/* Init DIB info for buffer */
	dibinf = malloc(sizeof(BITMAPINFO) + 12);
	assert(dibinf);
	dibinf->bmiHeader.biSize = sizeof(dibinf->bmiHeader);
	dibinf->bmiHeader.biPlanes = 1;
	dibinf->bmiHeader.biBitCount = 32;
	dibinf->bmiHeader.biCompression = BI_RGB;
	dibinf->bmiHeader.biXPelsPerMeter = 2834;
	dibinf->bmiHeader.biYPelsPerMeter = 2834;
	dibinf->bmiHeader.biClrUsed = 0;
	dibinf->bmiHeader.biClrImportant = 0;
	dibinf->bmiHeader.biClrUsed = 0;

	/* Create window */
	hwndframe = CreateWindowW(L"FrameWindow", // window class name
	NULL, // window caption
	WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
	CW_USEDEFAULT, CW_USEDEFAULT, // initial position
	300, // initial x size
	300, // initial y size
	0, // parent window handle
	0, // window menu handle
	0, // program instance handle
	0); // creation parameters
	if (!hwndframe)
		winerror(&gapp, "cannot create frame");

	hwndview = CreateWindowW(L"ViewWindow", // window class name
	NULL,
	WS_VISIBLE | WS_CHILD,
	CW_USEDEFAULT, CW_USEDEFAULT,
	CW_USEDEFAULT, CW_USEDEFAULT,
	hwndframe, 0, 0, 0);
	if (!hwndview)
		winerror(&gapp, "cannot create view");

	hdc = NULL;

	SetWindowTextW(hwndframe, L"MuPDF");

	menu = GetSystemMenu(hwndframe, 0);
	AppendMenuW(menu, MF_SEPARATOR, 0, NULL);
	AppendMenuW(menu, MF_STRING, ID_ABOUT, L"About MuPDF...");
	AppendMenuW(menu, MF_STRING, ID_DOCINFO, L"Document Properties...");

	SetCursor(arrowcurs);
}
Beispiel #23
0
HICON WINAPI FIX(LoadIconA)(HINSTANCE hInstance, LPCSTR lpIconName)
{
    return (HICON)LoadIconA(hInstance, lpIconName);
}
Beispiel #24
0
/*************************************************************************
 *			InternalExtractIcon		[SHELL.39]
 *
 * This abortion is called directly by Progman
 */
HGLOBAL16 WINAPI InternalExtractIcon16(HINSTANCE16 hInstance,
                                     LPCSTR lpszExeFileName, UINT16 nIconIndex, WORD n )
{
    HGLOBAL16 hRet = 0;
    HICON16 *RetPtr = NULL;
    OFSTRUCT ofs;
    HFILE hFile;

	TRACE("(%04x,file %s,start %d,extract %d\n",
		       hInstance, lpszExeFileName, nIconIndex, n);

	if( !n )
	  return 0;

	hFile = OpenFile( lpszExeFileName, &ofs, OF_READ|OF_EXIST );

	hRet = GlobalAlloc16( GMEM_FIXED | GMEM_ZEROINIT, sizeof(HICON16)*n);
	RetPtr = (HICON16*)GlobalLock16(hRet);

	if (hFile == HFILE_ERROR)
	{ /* not found - load from builtin module if available */
	  HINSTANCE hInst = (HINSTANCE)LoadLibrary16(lpszExeFileName);

	  if (hInst < 32) /* hmm, no Win16 module - try Win32 :-) */
	    hInst = LoadLibraryA(lpszExeFileName);
	  if (hInst)
	  {
	    int i;
	    for (i=nIconIndex; i < nIconIndex + n; i++)
	      RetPtr[i-nIconIndex] =
		      (HICON16)LoadIconA(hInst, (LPCSTR)(DWORD)i);
	    FreeLibrary(hInst);
	    return hRet;
	  }
          GlobalFree16( hRet );
	  return 0;
	}

        if (nIconIndex == (UINT16)-1)  /* get number of icons */
        {
            RetPtr[0] = PrivateExtractIconsA( ofs.szPathName, -1, 0, 0, NULL, 0, 0, 0 );
        }
        else
        {
            HRESULT res;
            HICON *icons;
            icons = HeapAlloc( GetProcessHeap(), 0, n * sizeof(*icons) );
            res = PrivateExtractIconsA( ofs.szPathName, nIconIndex,
                                        GetSystemMetrics(SM_CXICON),
                                        GetSystemMetrics(SM_CYICON),
                                        icons, 0, n, 0 );
            if (!res)
            {
                int i;
                for (i = 0; i < n; i++) RetPtr[i] = (HICON16)icons[i];
            }
            else
            {
                GlobalFree16( hRet );
                hRet = 0;
            }
            HeapFree( GetProcessHeap(), 0, icons );
        }
        return hRet;
}
void FsOpenWindow(int x0,int y0,int wid,int hei,int useDoubleBuffer)
{
	if(NULL!=fsWin32Internal.hWnd)
	{
		MessageBoxA(fsWin32Internal.hWnd,"Error! Window already exists.","Error!",MB_OK);
		exit(1);
	}

	// Note 2012/03/08 RegisterClassW and CreateWindowW doesn't seem to work.
	WNDCLASSA wc;
	HINSTANCE inst=GetModuleHandleA(NULL);

	wc.style=CS_OWNDC|CS_BYTEALIGNWINDOW;
	wc.lpfnWndProc=(WNDPROC)WindowFunc;
	wc.cbClsExtra=0;
	wc.cbWndExtra=0;
	wc.hInstance=(HINSTANCE)inst;
	wc.hIcon=LoadIconA(inst,"MAINICON");
	wc.hCursor=LoadCursor(NULL,IDC_ARROW);
	wc.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
	wc.lpszMenuName=NULL;
	wc.lpszClassName=WINCLASS;
	if(0!=RegisterClassA(&wc))
	{
		doubleBuffer=useDoubleBuffer;


		RECT rc;
		rc.left  =x0;
		rc.top   =y0;
		rc.right =(unsigned long)(x0+wid-1);
		rc.bottom=(unsigned long)(y0+hei-1);
		AdjustWindowRect(&rc,WINSTYLE,FALSE);
		wid  =rc.right-rc.left+1;
		hei  =rc.bottom-rc.top+1;

#ifdef _UNICODE
		// What's the point of using CreateWindowA?  Another weird Microsoft logic here.
		static wchar_t buf[256];
		const char *windowNameA=(const char *)WINNAME;
		for(int i=0; i<255 && 0!=windowNameA[i]; ++i)
		{
			buf[i]=windowNameA[i];
			buf[i+1]=0;
		}
		const char *windowNameUsed=(const char *)buf;
#else
		const char *windowNameUsed=(const char *)WINNAME;
#endif

		fsWin32Internal.hWnd=CreateWindowA(WINCLASS,windowNameUsed,WINSTYLE,x0,y0,wid,hei,NULL,NULL,inst,NULL);
		if(NULL!=fsWin32Internal.hWnd)
		{
			InitializeOpenGL(fsWin32Internal.hWnd);

			ShowWindow(fsWin32Internal.hWnd,SW_SHOWNORMAL);
			UpdateWindow(fsWin32Internal.hWnd);

			FsPassedTime();  // Reset Timer
		}
		else
		{
			printf("Could not open window.\n");
			exit(1);
		}
	}
}
//================================About dialog window=============================//
BOOL CALLBACK DialogProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
  switch(Message)
  {
        
         // This Window Message will close the dialog  //
		//============================================//

        case WM_CLOSE:
        {
          PostQuitMessage(0);
          EndDialog(hWnd,0); // kill dialog
        }
        break;

		case WM_NOTIFY:
		{
			switch(LOWORD(wParam))
			{
			    case IDC_LIST: 
				LPNMLISTVIEW pnm = (LPNMLISTVIEW)lParam;

                if(pnm->hdr.hwndFrom == hList &&pnm->hdr.code == NM_CUSTOMDRAW)
                {
                    SetWindowLong(hWnd, DWL_MSGRESULT, (LONG)ProcessCustomDraw(lParam));
                    return TRUE;
                }
				
                if(((LPNMHDR)lParam)->code == NM_DBLCLK)
				{
				  char Text[255]={0};  
				  char Temp[255]={0};
				  char Temp1[255]={0};
				  int iSlected=0;
				  int j=0;

				  iSlected=SendMessage(hList,LVM_GETNEXTITEM,-1,LVNI_FOCUSED);
				  
				  if(iSlected==-1)
				  {
                    MessageBox(hWnd,"No Items in ListView","Error",MB_OK|MB_ICONINFORMATION);
					break;
				  }

				  memset(&LvItem,0,sizeof(LvItem));
                  LvItem.mask=LVIF_TEXT;
				  LvItem.iSubItem=0;
				  LvItem.pszText=Text;
				  LvItem.cchTextMax=256;
				  LvItem.iItem=iSlected;
                  
				  SendMessage(hList,LVM_GETITEMTEXT, iSlected, (LPARAM)&LvItem);
				  
				  sprintf(Temp1,Text);
				  
				  for(j=1;j<=5;j++)
				  {
					LvItem.iSubItem=j;
				    SendMessage(hList,LVM_GETITEMTEXT, iSlected, (LPARAM)&LvItem);
				    sprintf(Temp," %s",Text);
					lstrcat(Temp1,Temp);
				  }

				  MessageBox(hWnd,Temp1,"test",MB_OK);

				}
				if(((LPNMHDR)lParam)->code == NM_CLICK)
				{
					iSelect=SendMessage(hList,LVM_GETNEXTITEM,-1,LVNI_FOCUSED);
				    
					if(iSelect==-1)
					{                      
					  break;
					}
					index=iSelect;
					flag=1;
				}

                if(((LPNMHDR)lParam)->code == LVN_BEGINLABELEDIT)
                {
                  //Editing=1;
                  hEdit=ListView_GetEditControl(hList);
                  GetWindowText(hEdit, tempstr, sizeof(tempstr));
                }
				
                if(((LPNMHDR)lParam)->code == LVN_ENDLABELEDIT)
                {
                    int iIndex;
                    char text[255]="";

                    tchar = (TCHAR)msg.wParam;
                    if(tchar == 0x1b)
                          escKey=1;

                    iIndex=SendMessage(hList,LVM_GETNEXTITEM,-1,LVNI_FOCUSED);
                    if(iIndex==-1)
					   break;
					
					LvItem.iSubItem=0;
                                       
                    if(escKey==0)
					{
						LvItem.pszText=text; 
						GetWindowText(hEdit, text, sizeof(text));
                        SendMessage(hList,LVM_SETITEMTEXT,(WPARAM)iIndex,(LPARAM)&LvItem);
					}
                    else{
                        LvItem.pszText=tempstr;
                        SendMessage(hList,LVM_SETITEMTEXT,(WPARAM)iIndex,(LPARAM)&LvItem);
                        escKey=0;
                    }
                    //Editing=0;
                }
                break;
			}
		}

		case WM_PAINT:
			{
				return 0;
			}
			break;

		// This Window Message is the heart of the dialog  //
		//================================================//
		case WM_INITDIALOG:
			{
                int i;
				char Temp[255];
				LVBKIMAGE plvbki={0};
				char url[]="C:\\a.jpg";
				InitCommonControls();
				hList=GetDlgItem(hWnd,IDC_LIST); // get the ID of the ListView				 
				
				memset(&plvbki,0,sizeof(plvbki));
				plvbki.ulFlags=LVBKIF_SOURCE_URL;
				plvbki.pszImage=url;
				plvbki.xOffsetPercent=40;
				plvbki.yOffsetPercent=15;
				OleInitialize(NULL);
				
				SendMessage(hList,LVM_SETTEXTBKCOLOR, 0,(LPARAM)CLR_NONE);
				SendMessage(hList,LVM_SETBKIMAGE,0,(LPARAM)(LPLVBKIMAGE)&plvbki);
				
                SendMessage(hList,LVM_SETEXTENDEDLISTVIEWSTYLE,0,LVS_EX_FULLROWSELECT); // Set style
				
				SendMessageA(hWnd,WM_SETICON,(WPARAM) 1,(LPARAM) LoadIconA(hInst,MAKEINTRESOURCE(IDI_ICON1)));
			
				// Here we put the info on the Coulom headers
				// this is not data, only name of each header we like
                memset(&LvCol,0,sizeof(LvCol)); // Reset Coluom
				LvCol.mask=LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM; // Type of mask
				LvCol.cx=0x28;                                // width between each coloum
				LvCol.pszText="Item";                     // First Header
 				LvCol.cx=0x42;

				// Inserting Couloms as much as we want
				SendMessage(hList,LVM_INSERTCOLUMN,0,(LPARAM)&LvCol); // Insert/Show the coloum
				LvCol.pszText="Sub Item1";                          // Next coloum
                SendMessage(hList,LVM_INSERTCOLUMN,1,(LPARAM)&LvCol); // ...
				LvCol.pszText="Sub Item2";                       //
                SendMessage(hList,LVM_INSERTCOLUMN,2,(LPARAM)&LvCol); //
				LvCol.pszText="Sub Item3";                              //
                SendMessage(hList,LVM_INSERTCOLUMN,3,(LPARAM)&LvCol); //
				LvCol.pszText="Sub Item4";                            //
                SendMessage(hList,LVM_INSERTCOLUMN,4,(LPARAM)&LvCol); //
				LvCol.pszText="Sub Item5";                      //
                SendMessage(hList,LVM_INSERTCOLUMN,5,(LPARAM)&LvCol); // ...same as above

                memset(&LvItem,0,sizeof(LvItem)); // Reset Item Struct
				
				//  Setting properties Of Items:

				LvItem.mask=LVIF_TEXT;   // Text Style
				LvItem.cchTextMax = 256; // Max size of test
                
				LvItem.iItem=0;          // choose item  
				LvItem.iSubItem=0;       // Put in first coluom
				LvItem.pszText="Item 0"; // Text to display (can be from a char variable) (Items)
                
				SendMessage(hList,LVM_INSERTITEM,0,(LPARAM)&LvItem); // Send to the Listview
				
				for(i=1;i<=5;i++) // Add SubItems in a loop
				{
					LvItem.iSubItem=i;
					sprintf(Temp,"SubItem %d",i);
					LvItem.pszText=Temp;
					SendMessage(hList,LVM_SETITEM,0,(LPARAM)&LvItem); // Enter text to SubItems
				}
				
				// lets add a new Item:
                LvItem.iItem=1;            // choose item  
				LvItem.iSubItem=0;         // Put in first coluom
				LvItem.pszText="Item 1";   // Text to display (can be from a char variable) (Items)
                SendMessage(hList,LVM_INSERTITEM,0,(LPARAM)&LvItem); // Send to the Listview

				for(i=1;i<=5;i++) // Add SubItems in a loop
				{
					LvItem.iSubItem=i;
					sprintf(Temp,"SubItem %d",i);
					LvItem.pszText=Temp;
					SendMessage(hList,LVM_SETITEM,0,(LPARAM)&LvItem); // Enter etxt to SubItems
				}
					                
                //ListView_SetItemState(hList,0,LVIS_SELECTED	,LVIF_STATE);
                ShowWindow(hWnd,SW_NORMAL); 
                UpdateWindow(hWnd); 

                while(TRUE)
                {
                
                    if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
                    {   
                        /*
                        if(msg.message==WM_CHAR)
                        {
                            tchar = (TCHAR)msg.wParam;
                            if(tchar == 0x1b)
                                escKey=1;

                        }
                        */
                        if(msg.message==WM_QUIT)// killing while looking for a message
                        {
                                break;
                        }
                        
                        
                        TranslateMessage(&msg);
                        DispatchMessage(&msg);
                    }                   
                }
			}
			break;

     // This Window Message will control the dialog  //
	//==============================================//
        case WM_COMMAND:
		{
                 switch(LOWORD(wParam)) // what we press on?
				 {

					   case IDC_ADDITEM:
						 {
                           int iItem;
						   char ItemText[100];

						   iItem=SendMessage(hList,LVM_GETITEMCOUNT,0,0);
                           
						   GetDlgItemText(hWnd,IDC_ADD,ItemText,100);

						   if((lstrlen(ItemText))==0)
						   {
							   MessageBox(hWnd,"Please Write Some Text","Error",MB_OK|MB_ICONINFORMATION);
						       break;
						   }

                           LvItem.iItem=iItem;            // choose item  
				           LvItem.iSubItem=0;         // Put in first coluom
				           LvItem.pszText=ItemText;   // Text to display (can be from a char variable) (Items)
                           SendMessage(hList,LVM_INSERTITEM,0,(LPARAM)&LvItem); // Send to the Listview
						 }
						 break;

					case IDC_ADDSUBITEM:
						{
                           int Item,i;
						   char SubItemText[100];

						   Item=SendMessage(hList,LVM_GETITEMCOUNT,0,0);
                           
						   GetDlgItemText(hWnd,IDC_ADDSUB,SubItemText,100);
						   
						   if((lstrlen(SubItemText))==0)
						   {
							   MessageBox(hWnd,"Please Write Some Text","Error",MB_OK|MB_ICONINFORMATION);
						       break;
						   }

						   LvItem.iItem=Item-1;            // choose item  
				           
						   for(i=1;i<=5;i++)
						   {
				              LvItem.pszText=SubItemText;   // Text to display (can be from a char variable) (Items)
                              LvItem.iSubItem=i;         // Put in first coluom
						      SendMessage(hList,LVM_SETITEM,0,(LPARAM)&LvItem);
						   }
						}
						break;

					case IDC_BOTH:
						{
                           int itemIndex,j;
						   char iSubItemText[100]="";
						   char iItemText[100]="";

						   itemIndex=SendMessage(hList,LVM_GETITEMCOUNT,0,0);
                           
						   GetDlgItemText(hWnd,IDC_ADD,iItemText,100);
						   GetDlgItemText(hWnd,IDC_ADDSUB,iSubItemText,100);
                           
						   if((lstrlen(iSubItemText) && lstrlen(iItemText))==0)
						   {
							   MessageBox(hWnd,"Please Write Some Text","Error",MB_OK|MB_ICONINFORMATION);
						       break;
						   }

						   LvItem.iItem=itemIndex;            // choose item  
				           LvItem.iSubItem=0;
						   LvItem.pszText=iItemText;
						   SendMessage(hList,LVM_INSERTITEM,0,(LPARAM)&LvItem);
						   
						   for(j=1;j<=5;j++)
						   {
				              LvItem.pszText=iSubItemText;   // Text to display (can be from a char variable) (Items)
                              LvItem.iSubItem=j;         // Put in first coluom
						      SendMessage(hList,LVM_SETITEM,0,(LPARAM)&LvItem);
						   }
						}
						break;

					case IDC_DELALL:
						SendMessage(hList,LVM_DELETEALLITEMS,0,0);
						break;

					case IDC_DELSELITEM:
						if(flag)
                           SendMessage(hList,LVM_DELETEITEM,iSelect,0);
						flag=0;
						break;

					case IDC_RENAME:
					{
						if(index==-1)
						{
						   MessageBox(hWnd,"Nothing to rename","error",MB_OK);
						}
						else{
							//Editing=1;
							SendMessage(hList,LVM_EDITLABEL ,(WPARAM)index,(LPARAM)0);
						}
					}
					break;

                    case IDC_SELECT_ALL:
                    {
                        ListView_SetItemState(hList, -1, 0, LVIS_SELECTED); // deselect all
                        SendMessage(hList,LVM_ENSUREVISIBLE ,(WPARAM)-1,FALSE); // Send to the Listview                        
                        ListView_SetItemState(hList,-1,LVIS_SELECTED ,LVIS_SELECTED);                
                    }
                    break;

                    case IDC_LAST_ITEM:
                    {            
                        int items;
                        items = SendMessage(hList,LVM_GETITEMCOUNT ,(WPARAM)0,(LPARAM)0);
                        items--;
                        ListView_SetItemState(hList, -1, 0, LVIS_SELECTED); // deselect all
                        SendMessage(hList,LVM_ENSUREVISIBLE ,(WPARAM)items,FALSE); // Send to the Listview
                        ListView_SetItemState(hList,items,LVIS_SELECTED ,LVIS_SELECTED);
                        ListView_SetItemState(hList,items,LVIS_FOCUSED ,LVIS_FOCUSED);
                        
                    }
                    break;

				 }
		}
        break;
    
	    default:
		{
             return FALSE;
		}
    }

	return TRUE;
}
Beispiel #27
0
/* At process attach */
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
{
    TRACE("WineD3D DLLMain Reason=%d\n", fdwReason);
    if (fdwReason == DLL_PROCESS_ATTACH)
    {
       HMODULE mod;
       char buffer[MAX_PATH+10];
       DWORD size = sizeof(buffer);
       HKEY hkey = 0;
       HKEY appkey = 0;
       DWORD len;
       WNDCLASSA wc;

       atifs_shader_backend.shader_dll_load_init();
       glsl_shader_backend.shader_dll_load_init();
       arb_program_shader_backend.shader_dll_load_init();
       none_shader_backend.shader_dll_load_init();

       /* We need our own window class for a fake window which we use to retrieve GL capabilities */
       /* We might need CS_OWNDC in the future if we notice strange things on Windows.
        * Various articles/posts about OpenGL problems on Windows recommend this. */
       wc.style                = CS_HREDRAW | CS_VREDRAW;
       wc.lpfnWndProc          = DefWindowProcA;
       wc.cbClsExtra           = 0;
       wc.cbWndExtra           = 0;
       wc.hInstance            = hInstDLL;
       wc.hIcon                = LoadIconA(NULL, (LPCSTR)IDI_WINLOGO);
       wc.hCursor              = LoadCursorA(NULL, (LPCSTR)IDC_ARROW);
       wc.hbrBackground        = NULL;
       wc.lpszMenuName         = NULL;
       wc.lpszClassName        = "WineD3D_OpenGL";

       if (!RegisterClassA(&wc) && GetLastError() != ERROR_CLASS_ALREADY_EXISTS)
       {
           ERR("Failed to register window class 'WineD3D_OpenGL'!\n");
           return FALSE;
       }

       DisableThreadLibraryCalls(hInstDLL);

       mod = GetModuleHandleA( "winex11.drv" );
       if (mod)
       {
           wine_tsx11_lock_ptr   = (void *)GetProcAddress( mod, "wine_tsx11_lock" );
           wine_tsx11_unlock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_unlock" );
       }
       else /* We are most likely on Windows */
       {
           wine_tsx11_lock_ptr   = wined3d_do_nothing;
           wine_tsx11_unlock_ptr = wined3d_do_nothing;
       }
       /* @@ Wine registry key: HKCU\Software\Wine\Direct3D */
       if ( RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Direct3D", &hkey ) ) hkey = 0;

       len = GetModuleFileNameA( 0, buffer, MAX_PATH );
       if (len && len < MAX_PATH)
       {
            HKEY tmpkey;
            /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\Direct3D */
            if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\AppDefaults", &tmpkey ))
            {
                char *p, *appname = buffer;
                if ((p = strrchr( appname, '/' ))) appname = p + 1;
                if ((p = strrchr( appname, '\\' ))) appname = p + 1;
                strcat( appname, "\\Direct3D" );
                TRACE("appname = [%s]\n", appname);
                if (RegOpenKeyA( tmpkey, appname, &appkey )) appkey = 0;
                RegCloseKey( tmpkey );
            }
       }

       if ( 0 != hkey || 0 != appkey )
       {
            if ( !get_config_key( hkey, appkey, "VertexShaderMode", buffer, size) )
            {
                if (!strcmp(buffer,"none"))
                {
                    TRACE("Disable vertex shaders\n");
                    wined3d_settings.vs_mode = VS_NONE;
                }
            }
            if ( !get_config_key( hkey, appkey, "PixelShaderMode", buffer, size) )
            {
                if (!strcmp(buffer,"enabled"))
                {
                    TRACE("Allow pixel shaders\n");
                    wined3d_settings.ps_mode = PS_HW;
                }
                if (!strcmp(buffer,"disabled"))
                {
                    TRACE("Disable pixel shaders\n");
                    wined3d_settings.ps_mode = PS_NONE;
                }
            }
            if ( !get_config_key( hkey, appkey, "VertexBufferMode", buffer, size) )
            {
                if (!strcmp(buffer,"none"))
                {
                    TRACE("Disable Vertex Buffer Hardware support\n");
                    wined3d_settings.vbo_mode = VBO_NONE;
                }
                else if (!strcmp(buffer,"hardware"))
                {
                    TRACE("Allow Vertex Buffer Hardware support\n");
                    wined3d_settings.vbo_mode = VBO_HW;
                }
            }
            if ( !get_config_key( hkey, appkey, "UseGLSL", buffer, size) )
            {
                if (!strcmp(buffer,"disabled"))
                {
                    TRACE("Use of GL Shading Language disabled\n");
                    wined3d_settings.glslRequested = FALSE;
                }
            }
            if ( !get_config_key( hkey, appkey, "OffscreenRenderingMode", buffer, size) )
            {
                if (!strcmp(buffer,"backbuffer"))
                {
                    TRACE("Using the backbuffer for offscreen rendering\n");
                    wined3d_settings.offscreen_rendering_mode = ORM_BACKBUFFER;
                }
                else if (!strcmp(buffer,"pbuffer"))
                {
                    TRACE("Using PBuffers for offscreen rendering\n");
                    wined3d_settings.offscreen_rendering_mode = ORM_PBUFFER;
                }
                else if (!strcmp(buffer,"fbo"))
                {
                    TRACE("Using FBOs for offscreen rendering\n");
                    wined3d_settings.offscreen_rendering_mode = ORM_FBO;
                }
            }
            if ( !get_config_key( hkey, appkey, "RenderTargetLockMode", buffer, size) )
            {
                if (!strcmp(buffer,"disabled"))
                {
                    TRACE("Disabling render target locking\n");
                    wined3d_settings.rendertargetlock_mode = RTL_DISABLE;
                }
                else if (!strcmp(buffer,"readdraw"))
                {
                    TRACE("Using glReadPixels for render target reading and glDrawPixels for writing\n");
                    wined3d_settings.rendertargetlock_mode = RTL_READDRAW;
                }
                else if (!strcmp(buffer,"readtex"))
                {
                    TRACE("Using glReadPixels for render target reading and textures for writing\n");
                    wined3d_settings.rendertargetlock_mode = RTL_READTEX;
                }
                else if (!strcmp(buffer,"texdraw"))
                {
                    TRACE("Using textures for render target reading and glDrawPixels for writing\n");
                    wined3d_settings.rendertargetlock_mode = RTL_TEXDRAW;
                }
                else if (!strcmp(buffer,"textex"))
                {
                    TRACE("Reading render targets via textures and writing via textures\n");
                    wined3d_settings.rendertargetlock_mode = RTL_TEXTEX;
                }
            }
            if ( !get_config_key( hkey, appkey, "VideoMemorySize", buffer, size) )
            {
                int TmpVideoMemorySize = atoi(buffer);
                if(TmpVideoMemorySize > 0)
                {
                    wined3d_settings.emulated_textureram = TmpVideoMemorySize *1024*1024;
                    TRACE("Use %iMB = %d byte for emulated_textureram\n",
                            TmpVideoMemorySize,
                            wined3d_settings.emulated_textureram);
                }
                else
                    ERR("VideoMemorySize is %i but must be >0\n", TmpVideoMemorySize);
            }
            if ( !get_config_key( hkey, appkey, "WineLogo", buffer, size) )
            {
                wined3d_settings.logo = HeapAlloc(GetProcessHeap(), 0, strlen(buffer) + 1);
                if(wined3d_settings.logo) strcpy(wined3d_settings.logo, buffer);
            }
            if ( !get_config_key( hkey, appkey, "Multisampling", buffer, size) )
            {
                if (!strcmp(buffer,"enabled"))
                {
                    TRACE("Allow multisampling\n");
                    wined3d_settings.allow_multisampling = TRUE;
                }
            }
       }
       if (wined3d_settings.vs_mode == VS_HW)
           TRACE("Allow HW vertex shaders\n");
       if (wined3d_settings.ps_mode == PS_NONE)
           TRACE("Disable pixel shaders\n");
       if (wined3d_settings.vbo_mode == VBO_NONE)
           TRACE("Disable Vertex Buffer Hardware support\n");
       if (wined3d_settings.glslRequested)
           TRACE("If supported by your system, GL Shading Language will be used\n");

       if (appkey) RegCloseKey( appkey );
       if (hkey) RegCloseKey( hkey );
    }
    return TRUE;
}
Beispiel #28
0
// address: 0x4010e0
void _start(char param1, unsigned char param2, __size32 param3, __size32 param4, __size32 param5) {
    __size32 eax; 		// r24
    __size32 eax_1; 		// r24{18}
    int ecx; 		// r25
    int edx; 		// r26
    int esp; 		// r28
    __size32 *esp_1; 		// r28{116}
    __size32 *esp_2; 		// r28{147}
    __size32 *esp_3; 		// r28{251}
    __size32 *local10; 		// esp_3{251}
    unsigned int local6; 		// m[esp - 8]

    eax_1 = GetModuleHandleA();
    LoadIconA(0, 0x7f00);
    GetWindowsDirectoryA();
    ecx = (param2);
    if (ecx != 58) {
    }
    lstrcatA(&param1, "\hh.exe");
    eax = CreateFileA();
    if (eax != -1) {
        GetWindowsDirectoryA();
        edx = (param2);
        if (edx != 58) {
        }
        lstrcatA(&param1, "\hXCXXXXCXXAAXCh.exe");
        eax = CreateFileA(); /* Warning: also results in esp_1 */
        local10 = esp_1;
        if (eax == -1) {
            local6 = 0;
            esp_3 = local10;
            while (local6 < global67) {
                *(__size32*)(esp_3 - 4) = 0;
                esp_2 = GetModuleHandleA();
                local10 = esp_2;
                edx = local6 + 0x402333;
                eax = *(edx + 8);
                ecx = local6 + 0x402333;
                *(int*)(ecx + 8) = eax ^ 22;
                local6 += 8;
                esp_3 = local10;
            }
            *(__size32*)(esp_3 - 4) = global68;
            eax = proc1(*(esp_3 - 4));
            global73 = eax;
            *(unsigned int*)(esp_3 - 4) = global67;
            *(__size32*)(esp_3 - 8) = global73;
            *(__size32*)(esp_3 - 12) = 0x40233b;
            proc2(*(esp_3 - 184), *(esp_3 - 180), *(esp_3 - 48), *(esp_3 - 44), *(esp_3 - 32), *(esp_3 - 12), *(esp_3 - 8), *(esp_3 - 4));
            global76 = param5;
            global77 = param4;
            global78 = param3;
            ecx = *24;
            global27 = ecx;
            global80 = (esp - 4);
            *(__size32*)(esp_3 - 4) = eax_1;
            *(__size32*)(esp_3 - 8) = 0x40128f - eax_1;
            esp = proc3(*(esp_3 - 4));
            *(__size32*)(esp + 4) = global73;
            proc4(*(esp + 4));
/* goto m[0x406720]*/
        }
    } else {