示例#1
0
static BOOL TPack_InitializeDialog (HWND hwnd)
{
	TPack_WindowData *	pData;
	HFONT				Font;
	HWND				ListWnd;

	// allocate window local data structure
	pData = GE_RAM_ALLOCATE_STRUCT (TPack_WindowData);
	if (pData == NULL)
	{
		DestroyWindow (hwnd);
		return TRUE;
	}

	// and initialize it
	pData->Instance		 = (HINSTANCE)GetWindowLong (hwnd, GWL_HINSTANCE);
	pData->hwnd			 = hwnd;
	pData->BitmapCount	 = 0;
	pData->Bitmaps		 = NULL;
	pData->SelectedEntry = NULL;
	pData->FileNameIsValid = FALSE;
	pData->Dirty		 = FALSE;
	// Set the window data pointer in the GWL_USERDATA field
	SetWindowLong(hwnd, GWL_USERDATA, (LONG)pData);
	SetWindowLong(GetDlgItem(hwnd, IDC_PREVIEW), GWL_USERDATA, (LONG)pData);
	SetWindowLong(GetDlgItem(hwnd, IDC_PREVIEW), GWL_WNDPROC, (LONG)TPack_PreviewWndProc);

	ListWnd = GetDlgItem(hwnd, IDC_TEXTURELIST);
	SetWindowLong(ListWnd, GWL_USERDATA, (LONG)GetWindowLong(ListWnd, GWL_WNDPROC));
	SetWindowLong(ListWnd, GWL_WNDPROC, (LONG)TPack_ListBoxWndProc);
	
	Font = CreateFont( -24,
    					    0,0,0, 0,
    					    0,0,0,0,OUT_TT_ONLY_PRECIS ,0,0,0, "Arial Black");
    SendDlgItemMessage(hwnd, IDC_TEXTURESIZE, WM_SETFONT, (WPARAM)Font, MAKELPARAM(TRUE, 0));

	// set the program icon on the dialog window
	SendMessage (hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon (pData->Instance, MAKEINTRESOURCE (IDI_MAINICON)));

	DragAcceptFiles (hwnd, TRUE);

	return TRUE;
}
示例#2
0
文件: dcxedit.cpp 项目: dlsocool/dcx
DcxEdit::DcxEdit(const UINT ID, DcxDialog *p_Dialog, const HWND mParentHwnd, const RECT *rc, TString &styles)
: DcxControl(ID, p_Dialog)
{
	LONG Styles = 0, ExStyles = 0;
	BOOL bNoTheme = FALSE;
	this->parseControlStyles(styles, &Styles, &ExStyles, &bNoTheme);

	this->m_Hwnd = CreateWindowExW(
		ExStyles | WS_EX_CLIENTEDGE, 
		L"EDIT",
		NULL,
		WS_CHILD | Styles,
		rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top,
		mParentHwnd,
		(HMENU) ID,
		GetModuleHandle(NULL), 
		NULL);

	if (!IsWindow(this->m_Hwnd))
		throw "Unable To Create Window";

	if (bNoTheme)
		Dcx::UXModule.dcxSetWindowTheme(this->m_Hwnd , L" ", L" ");

	Edit_LimitText(this->m_Hwnd, 0);
	//this->m_tsText = "";

	//SendMessage(this->m_Hwnd, CCM_SETUNICODEFORMAT, TRUE, NULL);

	if (p_Dialog->getToolTip() != NULL) {
		if (styles.istok("tooltips")) {
			this->m_ToolTipHWND = p_Dialog->getToolTip();
			AddToolTipToolInfo(this->m_ToolTipHWND, this->m_Hwnd);
		}
	}

	this->m_bIgnoreRepeat = TRUE;
	this->setControlFont((HFONT) GetStockObject(DEFAULT_GUI_FONT), FALSE);
	this->registreDefaultWindowProc();
	SetProp(this->m_Hwnd, "dcx_cthis", (HANDLE) this);
	DragAcceptFiles(this->m_Hwnd, TRUE);
}
示例#3
0
bool Chkdraft::CreateSubWindows()
{
    HWND hWnd = getHandle();
    if ( hWnd != NULL )
    {
        DragAcceptFiles(hWnd, TRUE);
        int statusWidths[] = { 130, 205, 350, 450, 600, -1 };

        return mainMenu.FindThis(hWnd) &&
            mainToolbar.CreateThis(hWnd, IDR_MAIN_TOOLBAR) &&
            statusBar.CreateThis(sizeof(statusWidths) / sizeof(int), statusWidths, 0,
                WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, hWnd, (HMENU)IDR_MAIN_STATUS) &&
            mainPlot.CreateThis(hWnd, IDR_MAIN_PLOT) &&
            BecomeMDIFrame(maps, GetSubMenu(GetMenu(hWnd), 6), ID_MDI_FIRSTCHILD,
                WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
                0, 0, 0, 0, (HMENU)IDR_MAIN_MDI);
    }
    else
        return false;
}
示例#4
0
bool WaitingForYou::forePlay()
{
	// call parent
	Buddha::Game::forePlay();

	// input handler
	setInputMessageHandler(new InputMessageHandler);

	// create modules
	if (!createModules())
	{
		return false;
	}

	Record(Buddha::Logger::getInstancePtr()->getPath());

	//
	if (!setViewport())
	{
		return false;
	}

	//
	DragAcceptFiles(_hwnd, true);

	//
	if (!initGeometry())
	{
		return false;
	}

	//
	if (!createFonts())
	{
		return false;
	}

	setProcess(Buddha::eProcess_CreateModules);
	//
	return true;
}
示例#5
0
int WinD3DInit(  )
{
    // Register the window class
    WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
                      GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
                      "PhysView", NULL };
    RegisterClassEx( &wc );
	hInst = wc.hInstance;

    SetRect( &window_inset, 0, 0, 0, 0 );
    AdjustWindowRect( &window_inset, WS_OVERLAPPEDWINDOW, 0 );
    //RECT rc;
    //SetRect( &rc, 0, 0, Width, Height );
    //AdjustWindowRect( &rc, WS_OVERLAPPEDWINDOW, 0 );


    // Create the application's window
	Width = windowwidth;
	Height= windowheight;
    hWnd = CreateWindow( "PhysView", windowtitle,
                              WS_OVERLAPPEDWINDOW, windowx+window_inset.left, windowy+window_inset.top, Width+window_inset.right-window_inset.left, Height+window_inset.bottom-window_inset.top,
                              GetDesktopWindow(), NULL, wc.hInstance, NULL );
/* 	HWND parentwindow=GetDesktopWindow();
	parentwindow=(HWND)0xa0618;
   hWnd = CreateWindow( "PhysView", "PhysView",
                              WS_CHILD, 0, 0, 200,200,
                              parentwindow, NULL, wc.hInstance, NULL );
*/

    // Initialize Direct3D
    HRESULT hr;
	hr =  InitD3D( hWnd );

    // Show the window
    ShowWindow( hWnd, SW_SHOWDEFAULT );
    UpdateWindow( hWnd );
	DragAcceptFiles(hWnd,true);
	InitFont(g_pd3dDevice);

	return 1;
}
示例#6
0
BOOL CPPageExternalFilters::OnInitDialog()
{
	__super::OnInitDialog();

	DragAcceptFiles(TRUE);

	AppSettings& s = AfxGetAppSettings();

	m_pFilters.RemoveAll();

	POSITION pos = s.m_filters.GetHeadPosition();
	while (pos) {
		CAutoPtr<FilterOverride> f(DNew FilterOverride(s.m_filters.GetNext(pos)));

		CString name(_T("<unknown>"));

		if (f->type == FilterOverride::REGISTERED) {
			name = CFGFilterRegistry(f->dispname).GetName();
			if (name.IsEmpty()) {
				name = f->name + _T(" <not registered>");
			}
		} else if (f->type == FilterOverride::EXTERNAL) {
			name = f->name;
			if (f->fTemporary) {
				name += _T(" <temporary>");
			}
			if (!CPath(MakeFullPath(f->path)).FileExists()) {
				name += _T(" <not found!>");
			}
		}

		int i = m_filters.AddString(name);
		m_filters.SetCheck(i, f->fDisabled ? 0 : 1);
		m_filters.SetItemDataPtr(i, m_pFilters.AddTail(f));
	}

	UpdateData(FALSE);

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
示例#7
0
LRESULT MainDialog::OnInitDialog(HWND hwnd, LPARAM lp)
{
	WTL::CMessageLoop *loop = _Module.GetMessageLoop();
	loop->AddMessageFilter(this);
	
	DragAcceptFiles(*this, true);
	SetIcon(WTL::AtlLoadIconImage(IDI_MEDIAWIKI, 0,
		GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON)));
	SetIcon(WTL::AtlLoadIconImage(IDI_MEDIAWIKI, 0,
		GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)), false);
	
	EnableDlgItem(IDC_OPT_COMPRESS_FULL, false);
	EnableDlgItem(IDC_START, false);
	
	DoDataExchange();
	m_progress.SetRange(0, 100);
	
	m_waitcursor.LoadOEMCursor(IDC_WAIT);
	
	return false;
}
示例#8
0
//
//   函数: InitInstance(HINSTANCE, int)
//
//   目的: 保存实例句柄并创建主窗口
//
//   注释:
//
//        在此函数中,我们在全局变量中保存实例句柄并
//        创建和显示主程序窗口。
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
   HWND hWnd;

   hInst = hInstance; // 将实例句柄存储在全局变量中

   hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
      CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

   if (!hWnd)
   {
      return FALSE;
   }

   DragAcceptFiles(hWnd, TRUE);

   ShowWindow(hWnd, nCmdShow);
   UpdateWindow(hWnd);

   return TRUE;
}
示例#9
0
//drag and drop support, call after window was initialized
void system_window_init(){

	//drag and drop
	#if TARGET_OS == WIN
		SDL_SysWMinfo wmInfo;

		//set SDL version to WMinfo struct
		//-> maybe problems when not calling this macro before
		SDL_VERSION(&wmInfo.version);  

		if(SDL_GetWMInfo(&wmInfo) != SDL_TRUE) {
			cerr << "Error on getting WMInfo" << endl;
			return;
		}

		SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
		DragAcceptFiles(wmInfo.window, true); //afxwin.h
	#endif
	
	//other OS ...
}
示例#10
0
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;

	
	if (!m_wndToolBar.Create(this) ||
		!m_wndToolBar.LoadBitmap(IDR_MAINFRAME) ||
		!m_wndToolBar.SetButtons(buttons,
		  sizeof(buttons)/sizeof(UINT)))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}

	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}

	m_wndToolBar.DestroyWindow();
#if	0
	// TODO: Delete these three lines if you don't want the toolbar to
	//  be dockable
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndToolBar);

	// TODO: Remove this if you don't want tool tips
	m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
		CBRS_TOOLTIPS | CBRS_FLYBY);
#endif
	DragAcceptFiles(TRUE);

	return 0;
}
示例#11
0
void __declspec(dllexport) onDropFiles(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
{  
  HWND hwCtl;
  //LONG lwnd;
  nsFunction  callback;

  // get info from stack

  hwCtl = (HWND) popint();
  callback = (nsFunction) popint();

  if (!IsWindow(hwCtl))
    return;

  //lwnd = GetWindowLong(hwCtl, GWL_EXSTYLE);
  //SetWindowLong(hwCtl, GWL_EXSTYLE, lwnd | WS_EX_ACCEPTFILES);
	DragAcceptFiles(hwCtl, TRUE);

  pushint((nsFunction) callback);
//  pushint((int) hwCtl);

	if (hwCtl == g_window.hwWindow)
		SetWindowCallback(WND_CALLBACK_IDX(onDropFiles));
	else
		{
			//size_t id;
			//id = g_window.controlCount - 1;
			//MessageBox(g_window.hwWindow,"control dropfiles",NULL,MB_OK);
			//g_window.controls[id].oldWndProc = (WNDPROC) SetWindowLong(hwCtl, GWL_WNDPROC, (long) DropFilesWndProc);
			ctl = GetControl(hwCtl);
			if (ctl == NULL)
				return;
			ctl->oldWndProc = (WNDPROC) SetWindowLong(hwCtl, GWL_WNDPROC, (long) DropFilesWndProc);

			pushint((int) hwCtl);

			SetControlCallback(CTL_CALLBACK_IDX(onDropFiles));
		}
}
示例#12
0
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;

#if 0
        if (!m_wndToolBar.Create(this) ||
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}
#endif

	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}

#if 0
        // TODO: Remove this if you don't want tool tips or a resizeable toolbar
	m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
		CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

	// TODO: Delete these three lines if you don't want the toolbar to
	//  be dockable
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndToolBar);
#endif

        // We accept drag and drop files
        DragAcceptFiles();

        return 0;
}
示例#13
0
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner),
  theBuffer(NULL),
  stopped(true)
{
    DragAcceptFiles(this->Handle, TRUE);
    bmp = new Graphics::TBitmap;
    bmp->PixelFormat = pf24bit;

    bmp->Canvas->Font->Assign(FontDialog1->Font);
    charWidth = bmp->Canvas->TextWidth("A");
    charHeight = bmp->Canvas->TextHeight("A");

    SetWindowLong(txtFrameSize->Handle, GWL_STYLE, GetWindowLong(txtFrameSize->Handle, GWL_STYLE) | ES_NUMBER);
    SetWindowLong(txtMinDelta->Handle, GWL_STYLE, GetWindowLong(txtMinDelta->Handle, GWL_STYLE) | ES_NUMBER);
    SetWindowLong(txtMaxDelta->Handle, GWL_STYLE, GetWindowLong(txtMaxDelta->Handle, GWL_STYLE) | ES_NUMBER);
    SetWindowLong(txtMaxResults->Handle, GWL_STYLE, GetWindowLong(txtMaxResults->Handle, GWL_STYLE) | ES_NUMBER);

    Panel2->DoubleBuffered = true;

    RedrawBitmap();
}
示例#14
0
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
        return -1;

    if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
                               | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
            !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
    {
        TRACE0("Failed to create toolbar\n");
        return -1;      // fail to create
    }

    if (!m_wndStatusBar.Create(this) ||
            !m_wndStatusBar.SetIndicators(indicators,
                                          sizeof(indicators)/sizeof(UINT)))
    {
        TRACE0("Failed to create status bar\n");
        return -1;      // fail to create
    }

    // TODO: Delete these three lines if you don't want the toolbar to
    // Enable drag/drop open
    DragAcceptFiles(TRUE);
    //  be dockable
    m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
    EnableDocking(CBRS_ALIGN_ANY);
    DockControlBar(&m_wndToolBar);
    // add panes
    m_wndStatusBar.SetPaneInfo( PANE_LENGTH_UNIT, ID_SEPARATOR, SBPS_NORMAL, 25);
    m_wndStatusBar.SetPaneInfo( PANE_CURSOR_POSITION, ID_SEPARATOR, SBPS_NORMAL, 72);
    m_wndStatusBar.SetPaneInfo( PANE_IMAGE_SIZE, ID_SEPARATOR, SBPS_NORMAL, 72);
    m_wndStatusBar.SetPaneInfo( PANE_BIT_COUNT, ID_SEPARATOR, SBPS_NORMAL, 28);
    m_wndStatusBar.SetPaneInfo( PANE_REGION_ID, ID_SEPARATOR, SBPS_NORMAL, 60);
    m_wndStatusBar.SetPaneInfo( PANE_REGION_SIZE, ID_SEPARATOR, SBPS_NORMAL, 30);
    m_wndStatusBar.SetPaneInfo( PANE_RN_COUNT, ID_SEPARATOR, SBPS_NORMAL, 15);
    return 0;
}
示例#15
0
HWND WINAPI HookCreateWindowExA(DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam)
{
    RECT    rcWordArea;
    ULONG   Length;
    LPWSTR  ClassName, WindowName;
    HWND    hWnd;

    Length = StrLengthA(lpClassName) + 1;
    ClassName = (LPWSTR)AllocStack(Length * sizeof(WCHAR));
    AnsiToUnicode(ClassName, Length * sizeof(WCHAR), lpClassName, Length);

    Length = StrLengthA(lpWindowName) + 1;
    WindowName = (LPWSTR)AllocStack(Length * sizeof(WCHAR));
    AnsiToUnicode(WindowName, Length * sizeof(WCHAR), lpWindowName, Length);

    hWnd = CreateWindowExW(dwExStyle, ClassName, WindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
    if (hWnd == NULL)
        return hWnd;

    OrigWndProc = (WNDPROC)SetWindowLongPtrA(hWnd, GWLP_WNDPROC, (LONG_PTR)CMVS_MainWindowProc);
    DragAcceptFiles(hWnd, TRUE);

    return hWnd;
}
示例#16
0
文件: perfmon.c 项目: mingpen/OpenNT
int PASCAL WinMain (HINSTANCE hCurrentInstance,
        		    HINSTANCE hPrevInstance,
                    LPSTR lpszCmdLine, 
                    int nCmdShow)
   {  // WinMain
   MSG      msg;

   if (!PerfmonInitialize (hCurrentInstance, hPrevInstance, 
                           lpszCmdLine, nCmdShow))
      return (FALSE) ;

   DragAcceptFiles (hWndMain, TRUE) ;

   while (GetMessage (&msg, NULL, 0, 0))
      {
      if (!TranslateAccelerator(hWndMain, hAccelerators, &msg))
         {
         TranslateMessage (&msg) ;
         DispatchMessage (&msg) ;
         }
      }  // while

   return(msg.wParam);
   }
示例#17
0
// the constructor creates the window
Viewer::Viewer(HWND parent, const TCHAR *current_filename)
{
    DWORD styles;

    m_hwndViewer=NULL;
    m_dib = NULL;
    m_bits = NULL;
    m_errorflag=0;

    styles = WS_OVERLAPPEDWINDOW;
    styles &= ~WS_MINIMIZEBOX;
    m_hwndViewer=CreateWindow(
                     _T("TPNGVIEWER"),_T(""),styles,
                     CW_USEDEFAULT,  // horizontal position
                     CW_USEDEFAULT,	// vertical position
                     CW_USEDEFAULT,	// width
                     CW_USEDEFAULT,  // height
                     parent,NULL,globals.hInst,NULL);
    if(!m_hwndViewer) return;

    twpng_SetWindowPos(m_hwndViewer,&globals.window_prefs.viewer);
    SetCurrentFileName(current_filename);
    UpdateViewerWindowTitle();
    ShowWindow(m_hwndViewer,globals.window_prefs.viewer.max?SW_SHOWMAXIMIZED:SW_SHOWNOACTIVATE);
    GetClientRect(m_hwndViewer,&m_clientrect);

    // Allowing files to be droppped into the viewer window is sort of a hack,
    // but it's convenient. We have to be careful not to react to a dropped
    // file if the main application has a dialog box open that could be in the
    // middle of editing a file.
    DragAcceptFiles(m_hwndViewer,TRUE);

    m_dragging=0;
    m_imgpos_x = globals.viewer_imgpos_x;
    m_imgpos_y = globals.viewer_imgpos_y;
}
示例#18
0
/**********************************************************************
 *						Functions
 *********************************************************************/
BOOL CALLBACK IH_DlgMain(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch(uMsg)
    {
    case WM_INITDIALOG:
    {
        g_HWND=hwndDlg;
        EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_INLINE), FALSE);
        EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_COPY), FALSE);
    }
    return TRUE;

    case WM_HELP:
    {
        char id[10]="";
        sprintf(id, "%d", IDS_HELPINLINE);
        SetEnvironmentVariableA("HELPID", id);
        SetEnvironmentVariableA("HELPTITLE", "Inline Help");
        DialogBox(hInst, MAKEINTRESOURCE(DLG_HELP), hwndDlg, DlgHelp);
    }
    return TRUE;

    case WM_BROWSE:
    {
        strcpy(g_szFileName, (const char*)wParam);
        //Retrieve the directory of the file.
        int i=strlen(g_szFileName)-1;
        int j=0;
        while(g_szFileName[i]!='\\')
        {
            i--;
            j++;
        }
        strncpy(g_szTargetDir, g_szFileName, strlen(g_szFileName)-j-1);

        //Retrieve stuff.
        EnableWindow(GetDlgItem(g_HWND, IDC_BTN_INLINE), FALSE);
        EnableWindow(GetDlgItem(g_HWND, IDC_BTN_COPY), FALSE);
        SendDlgItemMessageA(g_HWND, IDC_EDT_OEP, EM_SETREADONLY, 0, 0); //Enable change of OEP...
        DragAcceptFiles(g_HWND, FALSE);

        g_FileIsDll=IH_Debugger(g_szFileName, &g_TargetData, IH_DebugEnd_Callback, IH_ErrorMessageCallback);
    }
    return TRUE;

    case WM_DROPFILES:
    {
        //Get the dropped file name.
        DragQueryFileA((HDROP)wParam, 0, g_szFileName, 256);

        //Retrieve the directory of the file.
        int i=strlen(g_szFileName)-1;
        int j=0;
        while(g_szFileName[i]!='\\')
        {
            i--;
            j++;
        }
        strncpy(g_szTargetDir, g_szFileName, strlen(g_szFileName)-j-1);

        //Retrieve stuff.
        EnableWindow(GetDlgItem(g_HWND, IDC_BTN_INLINE), FALSE);
        EnableWindow(GetDlgItem(g_HWND, IDC_BTN_COPY), FALSE);
        SendDlgItemMessageA(g_HWND, IDC_EDT_OEP, EM_SETREADONLY, 0, 0); //Enable change of OEP...
        DragAcceptFiles(g_HWND, FALSE);

        g_FileIsDll=IH_Debugger(g_szFileName, &g_TargetData, IH_DebugEnd_Callback, IH_ErrorMessageCallback);
    }
    return TRUE;

    case WM_COMMAND:
    {
        switch(LOWORD(wParam))
        {
        case IDC_BTN_INLINE:
        {
            NoFocus();
            if(!(g_TargetData.EmptyEntry))
            {
                MessageBoxA(hwndDlg, "You need to specify the place to start the inline...", "N00B!", MB_ICONERROR);
                return TRUE;
            }
            char patch_filename[256]="";
            patch_filename[0]=0;
            OPENFILENAME ofstruct;
            memset(&ofstruct, 0, sizeof(ofstruct));
            ofstruct.lStructSize=sizeof(ofstruct);
            ofstruct.hwndOwner=hwndDlg;
            ofstruct.hInstance=hInst;
            if(!g_FileIsDll)
                ofstruct.lpstrFilter="Executable files (*.exe)\0*.exe\0\0";
            else
                ofstruct.lpstrFilter="Executable files (*.dll)\0*.dll\0\0";
            ofstruct.lpstrFile=patch_filename;
            ofstruct.nMaxFile=256;
            ofstruct.lpstrInitialDir=g_szTargetDir;
            ofstruct.lpstrTitle="Save file";
            if(!g_FileIsDll)
                ofstruct.lpstrDefExt="exe";
            else
                ofstruct.lpstrDefExt="dll";
            ofstruct.Flags=OFN_EXTENSIONDIFFERENT|OFN_HIDEREADONLY|OFN_NONETWORKBUTTON|OFN_OVERWRITEPROMPT;
            GetSaveFileName(&ofstruct);
            if(!patch_filename[0])
            {
                MessageBoxA(hwndDlg, "You must select a file...", "Warning", MB_ICONWARNING);
                return TRUE;
            }

            CopyFileA(g_szFileName, patch_filename, FALSE);
            SetPE32Data(patch_filename, 0, UE_OEP, g_TargetData.EmptyEntry-g_TargetData.ImageBase);
            long newflags=(long)GetPE32Data(patch_filename, g_TargetData.EntrySectionNumber, UE_SECTIONFLAGS);
            SetPE32Data(patch_filename, g_TargetData.EntrySectionNumber, UE_SECTIONFLAGS, (newflags|0x80000000));

            IH_GenerateAsmCode(g_codeText, g_TargetData);
            CopyToClipboard(g_codeText);
            MessageBoxA(hwndDlg, "1) Open the file you just saved with OllyDbg\n2) Open Multimate Assembler v1.5+\n3) Paste the code\n4) Modify the code to do something with the Security DLL\n5) Save the patched file with OllyDbg\n6) Enjoy!", "Instructions", MB_ICONINFORMATION);
        }
        return TRUE;

        case IDC_EDT_FREESPACE:
        {
            char free_temp[10]="";
            GetDlgItemTextA(hwndDlg, IDC_EDT_FREESPACE, free_temp, 10);
            sscanf(FormatTextHex(free_temp), "%X", &(g_TargetData.EmptyEntry));
        }
        return TRUE;

        case IDC_BTN_COPY:
        {
            NoFocus();
            if(g_codeText[0])
            {
                IH_GenerateAsmCode(g_codeText, g_TargetData);
                CopyToClipboard(g_codeText);
                MessageBoxA(hwndDlg, "Code copied to clipboard!", "Yay!", MB_ICONINFORMATION);
            }
            else
                MessageBoxA(hwndDlg, "There is no code to copy, please load a file first...", "Error!", MB_ICONERROR);
        }
        return TRUE;

        case IDC_BTN_PLUGINS:
        {
            NoFocus();
            PLUGFUNC PluginFunction;
            HINSTANCE PLUGIN_INST;
            char total_found_s[5]="";
            char plugin_name[100]="";
            char plugin_dll[100]="";
            char dll_to_load[256]="";
            char temp_str[5]="";
            int total_found=0;
            GetPrivateProfileStringA("Plugins", "total_found", "", total_found_s, 4, sg_szPluginIniFilePath);
            sscanf(total_found_s, "%d", &total_found);
            if(total_found)
            {
                HMENU myMenu=0;
                myMenu=CreatePopupMenu();
                for(int i=1; i!=(total_found+1); i++)
                {
                    sprintf(temp_str, "%d", i);
                    GetPrivateProfileStringA(temp_str, "plugin_name", "", plugin_name, 100, sg_szPluginIniFilePath);
                    AppendMenuA(myMenu, MF_STRING, i, plugin_name);
                }
                POINT cursorPos;
                GetCursorPos(&cursorPos);
                SetForegroundWindow(hwndDlg);
                UINT MenuItemClicked=TrackPopupMenu(myMenu, TPM_RETURNCMD|TPM_NONOTIFY, cursorPos.x, cursorPos.y, 0, hwndDlg, 0);
                SendMessage(hwndDlg, WM_NULL, 0, 0);
                if(!MenuItemClicked)
                    return TRUE;

                sprintf(temp_str, "%d", (int)MenuItemClicked);
                GetPrivateProfileStringA(temp_str, "plugin_dll", "", plugin_dll, 100, sg_szPluginIniFilePath);
                sprintf(dll_to_load, "plugins\\%s", plugin_dll);

                PLUGIN_INST=LoadLibraryA(dll_to_load);
                if(!PLUGIN_INST)
                    MessageBoxA(hwndDlg, "There was an error loading the plugin", plugin_dll, MB_ICONERROR);
                else
                {
                    PluginFunction=(PLUGFUNC)GetProcAddress(PLUGIN_INST, "PluginFunction");
                    if(!PluginFunction)
                        MessageBoxA(hwndDlg, "The export \"PluginFunction\" could not be found, please contact the plugin supplier", plugin_dll, MB_ICONERROR);
                    else
                    {
                        if(!g_TargetData.ImageBase)
                            g_TargetData.ImageBase=0x400000;

                        ShowWindow(GetParent(hwndDlg), 0);
                        PluginFunction(PLUGIN_INST, hwndDlg, g_TargetData.SecurityAddrRegister, sg_szAKTDirectory, g_TargetData.ImageBase);
                        ShowWindow(GetParent(hwndDlg), 1);
                        FreeLibrary(PLUGIN_INST);
                        SetForegroundWindow(hwndDlg);

                    }
                }
            }
            else
            {
                HMENU myMenu=0;
                myMenu=CreatePopupMenu();
                AppendMenuA(myMenu, MF_STRING|MF_GRAYED, 1, "No plugins found :(");
                POINT cursorPos;
                GetCursorPos(&cursorPos);
                SetForegroundWindow(hwndDlg);
                TrackPopupMenu(myMenu, TPM_RETURNCMD|TPM_NONOTIFY, cursorPos.x, cursorPos.y, 0, hwndDlg, 0);
            }
        }
        return TRUE;

        case IDC_EDT_OEP:
        {
            char temp_oep[10]="";
            GetDlgItemTextA(hwndDlg, IDC_EDT_OEP, temp_oep, 10);
            sscanf(temp_oep, "%X", &(g_TargetData.OEP));
        }
        return TRUE;
        }
    }
    return TRUE;
    }
    return FALSE;
}
示例#19
0
    MainWindow::MainWindow(QApplication* app)
		: main_page_(nullptr)
		, login_page_(nullptr)
#ifdef __APPLE__
        , accounts_page_(nullptr)
#endif //_APPLE__
		, app_(app)
		, event_filter_(new TitleWidgetEventFilter(this))
		, tray_icon_(new TrayIcon(this))
                , backgroundPixmap_(QPixmap())
        , Shadow_(0)
        , SkipRead_(false)
        , TaskBarIconHidden_(false)
        , liveChats_(new LiveChats(this))
	{
        Utils::InterConnector::instance().setMainWindow(this);

#ifdef _WIN32
        Utils::init_crash_handlers_in_core();
        core::dump::crash_handler chandler;
        chandler.set_process_exception_handlers();
        chandler.set_thread_exception_handlers();
#endif //_WIN32

		setStyleSheet(Utils::LoadStyle(":/main_window/main_window.qss", Utils::get_scale_coefficient(), true));
#ifdef __APPLE__
        mac_support_ = new MacSupport(this);
        mac_support_->enableMacCrashReport();
#endif

        app_->installNativeEventFilter(this);

        if (this->objectName().isEmpty())
            this->setObjectName(QStringLiteral("main_window"));
        this->resize(329, 331);
        QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
        sizePolicy.setHorizontalStretch(0);
        sizePolicy.setVerticalStretch(0);
        sizePolicy.setHeightForWidth(this->sizePolicy().hasHeightForWidth());
        this->setSizePolicy(sizePolicy);
        this->setLayoutDirection(Qt::LeftToRight);
        this->setAutoFillBackground(false);
        main_widget_ = new QWidget(this);
        main_widget_->setObjectName(QStringLiteral("main_widget"));
        sizePolicy.setHeightForWidth(main_widget_->sizePolicy().hasHeightForWidth());
        main_widget_->setSizePolicy(sizePolicy);
        vertical_layout_ = new QVBoxLayout(main_widget_);
        vertical_layout_->setSpacing(0);
        vertical_layout_->setObjectName(QStringLiteral("verticalLayout_9"));
        vertical_layout_->setSizeConstraint(QLayout::SetDefaultConstraint);
        vertical_layout_->setContentsMargins(0, 0, 0, 0);
        title_widget_ = new QWidget(main_widget_);
        title_widget_->setObjectName(QStringLiteral("title_widget"));
        QSizePolicy sizePolicy1(QSizePolicy::Preferred, QSizePolicy::Fixed);
        sizePolicy1.setHorizontalStretch(0);
        sizePolicy1.setVerticalStretch(0);
        sizePolicy1.setHeightForWidth(title_widget_->sizePolicy().hasHeightForWidth());
        title_widget_->setSizePolicy(sizePolicy1);
        title_widget_->setProperty("TitleWidget", QVariant(true));
        horizontal_layout_ = new QHBoxLayout(title_widget_);
        horizontal_layout_->setSpacing(0);
        horizontal_layout_->setObjectName(QStringLiteral("horizontalLayout"));
        horizontal_layout_->setContentsMargins(0, 0, 0, 0);
        logo_ = new QPushButton(title_widget_);
        logo_->setObjectName(QStringLiteral("logo"));
        QSizePolicy sizePolicy2(QSizePolicy::Fixed, QSizePolicy::Fixed);
        sizePolicy2.setHorizontalStretch(0);
        sizePolicy2.setVerticalStretch(0);
        sizePolicy2.setHeightForWidth(logo_->sizePolicy().hasHeightForWidth());
        logo_->setSizePolicy(sizePolicy2);
        logo_->setProperty("WindowIcon", QVariant(true));
        horizontal_layout_->addWidget(logo_);
        title_ = new QLabel(title_widget_);
        title_->setObjectName(QStringLiteral("title"));
        title_->setProperty("Title", QVariant(true));
        horizontal_layout_->addWidget(title_);
        horizontal_spacer_ = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
        horizontal_layout_->addItem(horizontal_spacer_);
        hide_button_ = new QPushButton(title_widget_);
        hide_button_->setObjectName(QStringLiteral("hide_button"));
        hide_button_->setProperty("HideButton", QVariant(true));
        horizontal_layout_->addWidget(hide_button_);
        maximize_button_ = new QPushButton(title_widget_);
        maximize_button_->setObjectName(QStringLiteral("maximize_button"));
        sizePolicy2.setHeightForWidth(maximize_button_->sizePolicy().hasHeightForWidth());
        maximize_button_->setSizePolicy(sizePolicy2);
        maximize_button_->setProperty("MaximizeButton", QVariant(true));
        horizontal_layout_->addWidget(maximize_button_);
        close_button_ = new QPushButton(title_widget_);
        close_button_->setObjectName(QStringLiteral("close_button"));
        sizePolicy2.setHeightForWidth(close_button_->sizePolicy().hasHeightForWidth());
        close_button_->setSizePolicy(sizePolicy2);
        close_button_->setProperty("CloseButton", QVariant(true));
        horizontal_layout_->addWidget(close_button_);
        vertical_layout_->addWidget(title_widget_);
        stacked_widget_ = new BackgroundWidget(main_widget_, "");
        stacked_widget_->setObjectName(QStringLiteral("stacked_widget"));

        QPixmap p(":/resources/main_window/pat_100.png");
        setBackgroundPixmap(p, true);

        //Utils::InterConnector::instance().setMainWindow(this);
        get_qt_theme_settings()->setOrLoadDefaultTheme();
        vertical_layout_->addWidget(stacked_widget_);
        this->setCentralWidget(main_widget_);

        logo_->setText(QString());
        hide_button_->setText(QString());
        maximize_button_->setText(QString());
        close_button_->setText(QString());

        stacked_widget_->setCurrentIndex(-1);
        QMetaObject::connectSlotsByName(this);

        if (!get_gui_settings()->get_value(settings_keep_logged_in, true))// || !get_gui_settings()->contains_value(settings_keep_logged_in))
        {
            showLoginPage();
        }
        else
        {
            showMainPage();
        }

		title_widget_->installEventFilter(event_filter_);
		title_->setText("ICQ");
		title_->setAttribute(Qt::WA_TransparentForMouseEvents);
		logo_->setAttribute(Qt::WA_TransparentForMouseEvents);

		setWindowTitle("ICQ");
#ifdef _WIN32
        setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint | Qt::WindowMinimizeButtonHint);
        fake_parent_window_ = Utils::create_fake_parent_window();
#else
        title_widget_->hide();
#endif

		title_->setMouseTracking(true);

		connect(hide_button_, SIGNAL(clicked()), this, SLOT(minimize()), Qt::QueuedConnection);
		connect(maximize_button_, SIGNAL(clicked()), this, SLOT(maximize()), Qt::QueuedConnection);
		connect(close_button_, SIGNAL(clicked()), this, SLOT(hideWindow()), Qt::QueuedConnection);

		hide_button_->setCursor(Qt::PointingHandCursor);
		maximize_button_->setCursor(Qt::PointingHandCursor);
		close_button_->setCursor(Qt::PointingHandCursor);

		connect(event_filter_, SIGNAL(doubleClick()), this, SLOT(maximize()), Qt::QueuedConnection);
		connect(event_filter_, SIGNAL(moveRequest(QPoint)), this, SLOT(moveRequest(QPoint)), Qt::QueuedConnection);

        connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipResetComplete()), this, SLOT(onVoipResetComplete()), Qt::QueuedConnection);

		connect(Ui::GetDispatcher(), SIGNAL(needLogin()), this, SLOT(showLoginPage()), Qt::DirectConnection);
		connect(&Utils::InterConnector::instance(), SIGNAL(showIconInTaskbar(bool)), this, SLOT(showIconInTaskbar(bool)), Qt::QueuedConnection);

        connect(this, SIGNAL(needActivate()), this, SLOT(activate()), Qt::QueuedConnection);

        connect(get_gui_settings(), SIGNAL(changed(QString)), this, SLOT(guiSettingsChanged(QString)), Qt::QueuedConnection);

		QFont f = QApplication::font();
		f.setStyleStrategy(QFont::PreferAntialias);
		QApplication::setFont(f);

        if (platform::is_windows())
        {
            int shadowWidth = get_gui_settings()->get_shadow_width();
            QBrush b = stacked_widget_->palette().background();
            QMatrix m;
            m.translate(shadowWidth, title_widget_->height() + shadowWidth);
            b.setMatrix(m);
            Shadow_ = new ShadowWindow(b, shadowWidth);
            QPoint pos = mapToGlobal(QPoint(rect().x(), rect().y()));
            Shadow_->move(pos.x(), pos.y());
            Shadow_->resize(rect().width(), rect().height());
            Shadow_->setActive(true);
            Shadow_->show();
        }

        initSettings();
#ifdef _WIN32
        DragAcceptFiles((HWND)winId(), TRUE);
#endif //_WIN32

        if (!get_gui_settings()->get_value<bool>(settings_show_in_taskbar, true))
            hide_taskbar_icon();

#ifdef __APPLE__
        mac_support_->enableMacUpdater();
        mac_support_->enableMacPreview(this->winId());
#endif

	}
示例#20
0
文件: main.c 项目: RPG-7/reactos
int WINAPI
_tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument, int nFunsterStil)
{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */

    TCHAR progtitle[1000];
    TCHAR resstr[100];
    HMENU menu;
    HWND hToolbar;
    HIMAGELIST hImageList;
    HANDLE haccel;
    HBITMAP tempBm;
    int i;
    TCHAR tooltips[16][30];
    HDC hDC;

    TCHAR *c;
    TCHAR sfnFilename[1000];
    TCHAR sfnFiletitle[256];
    TCHAR sfnFilter[1000];
    TCHAR ofnFilename[1000];
    TCHAR ofnFiletitle[256];
    TCHAR ofnFilter[1000];
    TCHAR miniaturetitle[100];
    static int custColors[16] = { 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
        0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff
    };

    /* init font for text tool */
    lfTextFont.lfHeight = 0;
    lfTextFont.lfWidth = 0;
    lfTextFont.lfEscapement = 0;
    lfTextFont.lfOrientation = 0;
    lfTextFont.lfWeight = FW_NORMAL;
    lfTextFont.lfItalic = FALSE;
    lfTextFont.lfUnderline = FALSE;
    lfTextFont.lfStrikeOut = FALSE;
    lfTextFont.lfCharSet = DEFAULT_CHARSET;
    lfTextFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
    lfTextFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
    lfTextFont.lfQuality = DEFAULT_QUALITY;
    lfTextFont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
    lstrcpy(lfTextFont.lfFaceName, _T(""));
    hfontTextFont = CreateFontIndirect(&lfTextFont);

    /* init palette */
    selectedPalette = 1;
    CopyMemory(palColors, modernPalColors, sizeof(palColors));

    hProgInstance = hThisInstance;

    /* initialize common controls library */
    InitCommonControls();

    /* register application defined window classes */
    RegisterWclMain();
    RegisterWclScrollbox();
    RegisterWclPal();
    RegisterWclSettings();
    RegisterWclSelection();
    RegisterWclSizebox();
    RegisterWclTextEdit();

    LoadString(hThisInstance, IDS_DEFAULTFILENAME, filename, SIZEOF(filename));
    LoadString(hThisInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr));
    _stprintf(progtitle, resstr, filename);
    LoadString(hThisInstance, IDS_MINIATURETITLE, miniaturetitle, SIZEOF(miniaturetitle));

    /* create main window */
    hwnd =
        CreateWindowEx(0, _T("MainWindow"), progtitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 544,
                       375, HWND_DESKTOP, NULL, hThisInstance, NULL);
    hMainWnd = hwnd;

    hwndMiniature =
        CreateWindowEx(WS_EX_PALETTEWINDOW, _T("MainWindow"), miniaturetitle,
                       WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME, 180, 200, 120, 100, hwnd,
                       NULL, hThisInstance, NULL);

    /* loading and setting the window menu from resource */
    menu = LoadMenu(hThisInstance, MAKEINTRESOURCE(ID_MENU));
    SetMenu(hwnd, menu);
    haccel = LoadAccelerators(hThisInstance, MAKEINTRESOURCE(800));

    /* preloading the draw transparent/nontransparent icons for later use */
    hNontranspIcon =
        LoadImage(hThisInstance, MAKEINTRESOURCE(IDI_NONTRANSPARENT), IMAGE_ICON, 40, 30, LR_DEFAULTCOLOR);
    hTranspIcon =
        LoadImage(hThisInstance, MAKEINTRESOURCE(IDI_TRANSPARENT), IMAGE_ICON, 40, 30, LR_DEFAULTCOLOR);

    hCurFill     = LoadIcon(hThisInstance, MAKEINTRESOURCE(IDC_FILL));
    hCurColor    = LoadIcon(hThisInstance, MAKEINTRESOURCE(IDC_COLOR));
    hCurZoom     = LoadIcon(hThisInstance, MAKEINTRESOURCE(IDC_ZOOM));
    hCurPen      = LoadIcon(hThisInstance, MAKEINTRESOURCE(IDC_PEN));
    hCurAirbrush = LoadIcon(hThisInstance, MAKEINTRESOURCE(IDC_AIRBRUSH));

    CreateWindowEx(0, _T("STATIC"), _T(""), WS_CHILD | WS_VISIBLE | SS_ETCHEDHORZ, 0, 0, 5000, 2, hwnd, NULL,
                   hThisInstance, NULL);

    hToolBoxContainer =
        CreateWindowEx(0, _T("MainWindow"), _T(""), WS_CHILD | WS_VISIBLE, 2, 2, 52, 350, hwnd, NULL,
                       hThisInstance, NULL);
    /* creating the 16 bitmap radio buttons and setting the bitmap */


    /*
     * FIXME: Unintentionally there is a line above the tool bar (hidden by y-offset).
     * To prevent cropping of the buttons height has been increased from 200 to 205
     */
    hToolbar =
        CreateWindowEx(0, TOOLBARCLASSNAME, NULL,
                       WS_CHILD | WS_VISIBLE | CCS_NOPARENTALIGN | CCS_VERT | CCS_NORESIZE | TBSTYLE_TOOLTIPS,
                       1, -2, 50, 205, hToolBoxContainer, NULL, hThisInstance, NULL);
    hImageList = ImageList_Create(16, 16, ILC_COLOR24 | ILC_MASK, 16, 0);
    SendMessage(hToolbar, TB_SETIMAGELIST, 0, (LPARAM) hImageList);
    tempBm = LoadImage(hThisInstance, MAKEINTRESOURCE(IDB_TOOLBARICONS), IMAGE_BITMAP, 256, 16, 0);
    ImageList_AddMasked(hImageList, tempBm, 0xff00ff);
    DeleteObject(tempBm);
    SendMessage(hToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);

    for(i = 0; i < 16; i++)
    {
        TBBUTTON tbbutton;
        int wrapnow = 0;

        if (i % 2 == 1)
            wrapnow = TBSTATE_WRAP;

        LoadString(hThisInstance, IDS_TOOLTIP1 + i, tooltips[i], 30);
        ZeroMemory(&tbbutton, sizeof(TBBUTTON));
        tbbutton.iString   = (INT_PTR) tooltips[i];
        tbbutton.fsStyle   = TBSTYLE_CHECKGROUP;
        tbbutton.fsState   = TBSTATE_ENABLED | wrapnow;
        tbbutton.idCommand = ID_FREESEL + i;
        tbbutton.iBitmap   = i;
        SendMessage(hToolbar, TB_ADDBUTTONS, 1, (LPARAM) &tbbutton);
    }

    SendMessage(hToolbar, TB_CHECKBUTTON, ID_PEN, MAKELONG(TRUE, 0));
    SendMessage(hToolbar, TB_SETMAXTEXTROWS, 0, 0);
    SendMessage(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(25, 25));

    /* creating the tool settings child window */
    hToolSettings =
        CreateWindowEx(0, _T("ToolSettings"), _T(""), WS_CHILD | WS_VISIBLE, 5, 208, 42, 140,
                       hToolBoxContainer, NULL, hThisInstance, NULL);
    hTrackbarZoom =
        CreateWindowEx(0, TRACKBAR_CLASS, _T(""), WS_CHILD | TBS_VERT | TBS_AUTOTICKS, 1, 1, 40, 64,
                       hToolSettings, NULL, hThisInstance, NULL);
    SendMessage(hTrackbarZoom, TBM_SETRANGE, (WPARAM) TRUE, (LPARAM) MAKELONG(0, 6));
    SendMessage(hTrackbarZoom, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) 3);

    /* creating the palette child window */
    hPalWin =
        CreateWindowEx(0, _T("Palette"), _T(""), WS_CHILD | WS_VISIBLE, 56, 9, 255, 32, hwnd, NULL,
                       hThisInstance, NULL);

    /* creating the scroll box */
    hScrollbox =
        CreateWindowEx(WS_EX_CLIENTEDGE, _T("Scrollbox"), _T(""),
                       WS_CHILD | WS_GROUP | WS_HSCROLL | WS_VSCROLL | WS_VISIBLE, 56, 49, 472, 248, hwnd,
                       NULL, hThisInstance, NULL);

    /* creating the status bar */
    hStatusBar =
        CreateWindowEx(0, STATUSCLASSNAME, _T(""), SBARS_SIZEGRIP | WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hwnd,
                       NULL, hThisInstance, NULL);
    SendMessage(hStatusBar, SB_SETMINHEIGHT, 21, 0);

    hScrlClient =
        CreateWindowEx(0, _T("Scrollbox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 500, 500, hScrollbox, NULL,
                       hThisInstance, NULL);

    /* create selection window (initially hidden) */
    hSelection =
        CreateWindowEx(WS_EX_TRANSPARENT, _T("Selection"), _T(""), WS_CHILD | BS_OWNERDRAW, 350, 0, 100, 100,
                       hScrlClient, NULL, hThisInstance, NULL);

    /* creating the window inside the scroll box, on which the image in hDrawingDC's bitmap is drawn */
    hImageArea =
        CreateWindowEx(0, _T("MainWindow"), _T(""), WS_CHILD | WS_VISIBLE, 3, 3, imgXRes, imgYRes, hScrlClient,
                       NULL, hThisInstance, NULL);

    hDC = GetDC(hImageArea);
    hDrawingDC = CreateCompatibleDC(hDC);
    hSelDC     = CreateCompatibleDC(hDC);
    ReleaseDC(hImageArea, hDC);
    SelectObject(hDrawingDC, CreatePen(PS_SOLID, 0, fgColor));
    SelectObject(hDrawingDC, CreateSolidBrush(bgColor));

    hBms[0] = CreateDIBWithProperties(imgXRes, imgYRes);
    SelectObject(hDrawingDC, hBms[0]);
    Rectangle(hDrawingDC, 0 - 1, 0 - 1, imgXRes + 1, imgYRes + 1);

    if (lpszArgument[0] != 0)
    {
        HBITMAP bmNew = NULL;
        LoadDIBFromFile(&bmNew, lpszArgument, &fileTime, &fileSize, &fileHPPM, &fileVPPM);
        if (bmNew != NULL)
        {
            TCHAR tempstr[1000];
            TCHAR resstr[100];
            TCHAR *temp;
            insertReversible(bmNew);
            GetFullPathName(lpszArgument, SIZEOF(filepathname), filepathname, &temp);
            _tcscpy(filename, temp);
            LoadString(hProgInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr));
            _stprintf(tempstr, resstr, filename);
            SetWindowText(hMainWnd, tempstr);
            clearHistory();
            isAFile = TRUE;
        }
        else
        {
            exit(0);
        }
    }

    /* initializing the CHOOSECOLOR structure for use with ChooseColor */
    choosecolor.lStructSize    = sizeof(CHOOSECOLOR);
    choosecolor.hwndOwner      = hwnd;
    choosecolor.hInstance      = NULL;
    choosecolor.rgbResult      = 0x00ffffff;
    choosecolor.lpCustColors   = (COLORREF*) &custColors;
    choosecolor.Flags          = 0;
    choosecolor.lCustData      = 0;
    choosecolor.lpfnHook       = NULL;
    choosecolor.lpTemplateName = NULL;

    /* initializing the OPENFILENAME structure for use with GetOpenFileName and GetSaveFileName */
    CopyMemory(ofnFilename, filename, sizeof(filename));
    LoadString(hThisInstance, IDS_OPENFILTER, ofnFilter, SIZEOF(ofnFilter));
    for(c = ofnFilter; *c; c++)
        if (*c == '\1')
            *c = '\0';
    ZeroMemory(&ofn, sizeof(OPENFILENAME));
    ofn.lStructSize    = sizeof(OPENFILENAME);
    ofn.hwndOwner      = hwnd;
    ofn.hInstance      = hThisInstance;
    ofn.lpstrFilter    = ofnFilter;
    ofn.lpstrFile      = ofnFilename;
    ofn.nMaxFile       = SIZEOF(ofnFilename);
    ofn.lpstrFileTitle = ofnFiletitle;
    ofn.nMaxFileTitle  = SIZEOF(ofnFiletitle);
    ofn.Flags          = OFN_HIDEREADONLY;

    CopyMemory(sfnFilename, filename, sizeof(filename));
    LoadString(hThisInstance, IDS_SAVEFILTER, sfnFilter, SIZEOF(sfnFilter));
    for(c = sfnFilter; *c; c++)
        if (*c == '\1')
            *c = '\0';
    ZeroMemory(&sfn, sizeof(OPENFILENAME));
    sfn.lStructSize    = sizeof(OPENFILENAME);
    sfn.hwndOwner      = hwnd;
    sfn.hInstance      = hThisInstance;
    sfn.lpstrFilter    = sfnFilter;
    sfn.lpstrFile      = sfnFilename;
    sfn.nMaxFile       = SIZEOF(sfnFilename);
    sfn.lpstrFileTitle = sfnFiletitle;
    sfn.nMaxFileTitle  = SIZEOF(sfnFiletitle);
    sfn.Flags          = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;

    /* creating the size boxes */
    hSizeboxLeftTop =
        CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL,
                       hThisInstance, NULL);
    hSizeboxCenterTop =
        CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL,
                       hThisInstance, NULL);
    hSizeboxRightTop =
        CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL,
                       hThisInstance, NULL);
    hSizeboxLeftCenter =
        CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL,
                       hThisInstance, NULL);
    hSizeboxRightCenter =
        CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL,
                       hThisInstance, NULL);
    hSizeboxLeftBottom =
        CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL,
                       hThisInstance, NULL);
    hSizeboxCenterBottom =
        CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL,
                       hThisInstance, NULL);
    hSizeboxRightBottom =
        CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL,
                       hThisInstance, NULL);
    /* placing the size boxes around the image */
    SendMessage(hImageArea, WM_SIZE, 0, 0);

    /* by moving the window, the things in WM_SIZE are done */
    MoveWindow(hwnd, 100, 100, 600, 450, TRUE);

    /* creating the text editor window for the text tool */
    hwndTextEdit =
        CreateWindowEx(0, _T("TextEdit"), _T(""), WS_OVERLAPPEDWINDOW, 300, 0, 300,
                       200, hwnd, NULL, hThisInstance, NULL);
    /* creating the edit control within the editor window */
    hwndEditCtl =
        CreateWindowEx(WS_EX_CLIENTEDGE, _T("EDIT"), _T(""),
                       WS_CHILD | WS_VISIBLE | WS_BORDER | WS_HSCROLL | WS_VSCROLL | ES_MULTILINE | ES_NOHIDESEL | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
                       0, 0, 100, 100, hwndTextEdit, NULL, hThisInstance, NULL);

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nFunsterStil);

    /* inform the system, that the main window accepts dropped files */
    DragAcceptFiles(hwnd, TRUE);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage(&messages, NULL, 0, 0))
    {
        TranslateAccelerator(hwnd, haccel, &messages);

        /* Translate virtual-key messages into character messages */
        TranslateMessage(&messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}
// Creates the GLFW window and rendering context
//
static int createWindow(_GLFWwindow* window,
                        const _GLFWwndconfig* wndconfig,
                        const _GLFWctxconfig* ctxconfig,
                        const _GLFWfbconfig* fbconfig)
{
    int xpos, ypos, fullWidth, fullHeight;
    WCHAR* wideTitle;

    window->win32.dwStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
    window->win32.dwExStyle = WS_EX_APPWINDOW;

    if (window->monitor)
    {
        window->win32.dwStyle |= WS_POPUP;

        // NOTE: This window placement is temporary and approximate, as the
        //       correct position and size cannot be known until the monitor
        //       video mode has been set
        _glfwPlatformGetMonitorPos(wndconfig->monitor, &xpos, &ypos);
        fullWidth  = wndconfig->width;
        fullHeight = wndconfig->height;
    }
    else
    {
        if (wndconfig->decorated)
        {
            window->win32.dwStyle |= WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;

            if (wndconfig->resizable)
            {
                window->win32.dwStyle |= WS_MAXIMIZEBOX | WS_SIZEBOX;
                window->win32.dwExStyle |= WS_EX_WINDOWEDGE;
            }
        }
        else
            window->win32.dwStyle |= WS_POPUP;

        xpos = CW_USEDEFAULT;
        ypos = CW_USEDEFAULT;

        getFullWindowSize(window,
                          wndconfig->width, wndconfig->height,
                          &fullWidth, &fullHeight);
    }

    wideTitle = _glfwCreateWideStringFromUTF8(wndconfig->title);
    if (!wideTitle)
    {
        _glfwInputError(GLFW_PLATFORM_ERROR,
                        "Win32: Failed to convert window title to UTF-16");
        return GL_FALSE;
    }

    window->win32.handle = CreateWindowExW(window->win32.dwExStyle,
                                           _GLFW_WNDCLASSNAME,
                                           wideTitle,
                                           window->win32.dwStyle,
                                           xpos, ypos,
                                           fullWidth, fullHeight,
                                           NULL, // No parent window
                                           NULL, // No window menu
                                           GetModuleHandleW(NULL),
                                           window); // Pass object to WM_CREATE

    free(wideTitle);

    if (!window->win32.handle)
    {
        _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to create window");
        return GL_FALSE;
    }

    if (_glfw_ChangeWindowMessageFilterEx)
    {
        _glfw_ChangeWindowMessageFilterEx(window->win32.handle,
                                          WM_DROPFILES, MSGFLT_ALLOW, NULL);
        _glfw_ChangeWindowMessageFilterEx(window->win32.handle,
                                          WM_COPYDATA, MSGFLT_ALLOW, NULL);
        _glfw_ChangeWindowMessageFilterEx(window->win32.handle,
                                          WM_COPYGLOBALDATA, MSGFLT_ALLOW, NULL);
    }

    if (wndconfig->floating && !wndconfig->monitor)
    {
        SetWindowPos(window->win32.handle,
                        HWND_TOPMOST,
                        0, 0, 0, 0,
                        SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
    }

    DragAcceptFiles(window->win32.handle, TRUE);

    if (!_glfwCreateContext(window, ctxconfig, fbconfig))
        return GL_FALSE;

    return GL_TRUE;
}
示例#22
0
/*
 * MainWindowProc - procedure for main (root) window
 */
WINEXPORT LRESULT CALLBACK MainWindowProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    RECT        rect;
    vi_rc       rc;
    HANDLE      hfileinfo;
    int         cnt, i;
    char        *buff;

    switch( msg ) {
    case WM_CREATE:
        Root = hwnd;
        GetClientRect( hwnd, &rect );
        EditContainer = CreateContainerWindow( &rect );
        InitWindows();
        DragAcceptFiles( hwnd, TRUE );
        timerID = SetTimer( hwnd, TIMER_ID, 60L * 1000L, NULL );
        break;
    case WM_DROPFILES:
        hfileinfo = (HANDLE) wparam;
        cnt = DragQueryFile( hfileinfo, (UINT)-1, NULL, 0 );
        buff = alloca( FILENAME_MAX + 2 );   /* we add a " at the beginning and at the end so we can handle path- and filenames with spaces */
        if( buff != NULL ) {
            buff[0] = '"';      /* one " at the beginning of the filename */
            for( i = 0; i < cnt; i++ ) {
                if( DragQueryFile( hfileinfo, i, buff + 1, FILENAME_MAX ) == (UINT)-1 ) {
                    break;
                }
                strcat( buff, "\"" );
                rc = EditFile( buff, FALSE );
                if( rc > ERR_NO_ERR ) {
                    Error( GetErrorMsg( rc ) );
                }
            }
        }
        DragFinish( hfileinfo );
        break;
    case WM_TIMER:
        UpdateStatusWindow();
        break;
    case WM_KEYDOWN:
        if( WindowsKeyPush( wparam, HIWORD( lparam ) ) ) {
            return( 0 );
        }
        break;
    case WM_SIZE:
        DefFrameProc( hwnd, EditContainer, msg, wparam, lparam );
        RootState = wparam;
        if( wparam != SIZE_MINIMIZED ) {
            ResizeRoot();
            GetWindowRect( hwnd, &RootRect );
            if( wparam != SIZE_MAXIMIZED ) {
                RootState = 0;
            }
        }
        return( 0 );
    case WM_MOVE:
        DefFrameProc( hwnd, EditContainer, msg, wparam, lparam );
        if( RootState != SIZE_MINIMIZED ) {
            GetWindowRect( hwnd, &RootRect );
        }
        return( 0 );
    case WM_ACTIVATEAPP:
        if( BAD_ID( CurrentWindow ) ) {
            break;
        }
        SetFocus( Root );
#if 0
        if( !wparam ) {
            InactiveWindow( CurrentWindow );
        } else {
            SendMessage( EditContainer, WM_MDIACTIVATE, (WPARAM)CurrentWindow, 0L );
        }
#endif
        if( wparam ) {
            ResetEditWindowCursor( CurrentWindow );
        } else {
            GoodbyeCursor( CurrentWindow );
        }
        break;
    case WM_MOUSEACTIVATE:
        SetFocus( hwnd );
        return( MA_ACTIVATE );
    case WM_SETFOCUS:
        if( BAD_ID( CurrentWindow ) ) {
            break;
        }
        if( !IsIconic( CurrentWindow ) ) {
            SendMessage( EditContainer, WM_MDIACTIVATE, (WPARAM)CurrentWindow, 0L );
            DCUpdate();
            SetWindowCursor();
            SetWindowCursorForReal();
            return( 0 );
        }
        break;
    case WM_NCLBUTTONDBLCLK:
        break;
    case WM_COMMAND:
        if( LOWORD( wparam ) > 0xF000 ) {
            break;
        } else {
            rc = MenuCommand( LOWORD( wparam ) );
            if( rc != MENU_COMMAND_NOT_HANDLED ) {
                DCUpdateAll();
                if( rc > ERR_NO_ERR ) {
                    char        *msg;
                    msg = GetErrorMsg( rc );
                    Error( msg );
                }
            }
            SetWindowCursor();
        }
        return( 0 );
    case WM_INITMENU:
        if( (HMENU)wparam == GetMenu( hwnd ) ) {
            HandleInitMenu( (HMENU)wparam );
        } else {
            ResetMenuBits();
        }
        break;
    case WM_MENUSELECT:
        HandleMenuSelect( wparam, lparam );
        break;
    case WM_ENDSESSION:
        if( wparam ) {
            ExitEditor( 0 );
            // will not return
        }
        return( 0 );
    case WM_QUERYENDSESSION:
        return( ExitWithPrompt( FALSE, TRUE ) );
    case WM_CLOSE:
        ExitWithPrompt( TRUE, TRUE );
        return( 0 );
#ifdef __NT__        
    case WM_MOUSEWHEEL:
        {
            int     i, increment;
            ULONG   linesPerNotch;
            HWND    activeWnd;
            
            activeWnd = (HWND)SendMessage( EditContainer, WM_MDIGETACTIVE, 0, 0 );
            SystemParametersInfo( SPI_GETWHEELSCROLLLINES, 0, &linesPerNotch, 0 );
            
            increment = GET_WHEEL_DELTA_WPARAM( wparam ) / 120;
                // see WM_MOUSEWHEEL-documentation for information about the "120"

            if( increment > 0 ) {
                for( i = 0; i < increment * (int)linesPerNotch; i++ ) {
                    SendMessage( activeWnd, WM_VSCROLL, SB_LINEUP, 0 );
                }
            } else {
                for( i = 0; i < (-increment) * (int)linesPerNotch; i++ ) {
                    SendMessage( activeWnd, WM_VSCROLL, SB_LINEDOWN, 0 );
                }
            }
        }
        return( 0 );
#endif
    case WM_DESTROY:
        DestroyToolBar();
        DragAcceptFiles( hwnd, FALSE );
        EditContainer = 0;
        if( timerID ) {
            KillTimer( hwnd, TIMER_ID );
        }
        return( 0 );
    }
    return( DefFrameProc( hwnd, EditContainer, msg, wparam, lparam ) );

} /* MainWindowProc */
示例#23
0
/***********************************************************************
 *
 *           WinMain
 */
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE prev, LPTSTR cmdline, int show)
{
    MSG         msg;
    HACCEL      hAccel;
    WNDCLASSEX  wndclass;
    HMONITOR    monitor;
    MONITORINFO info;
    INT         x, y;

    static const TCHAR className[] = _T("NPClass");
    static const TCHAR winName[]   = _T("Notepad");

    UNREFERENCED_PARAMETER(prev);

    aFINDMSGSTRING = (ATOM) RegisterWindowMessage(FINDMSGSTRING);

    ZeroMemory(&Globals, sizeof(Globals));
    Globals.hInstance       = hInstance;
    LoadSettings();

    ZeroMemory(&wndclass, sizeof(wndclass));
    wndclass.cbSize        = sizeof(wndclass);
    wndclass.lpfnWndProc   = NOTEPAD_WndProc;
    wndclass.hInstance     = Globals.hInstance;
    wndclass.hIcon         = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_NPICON));
    wndclass.hCursor       = LoadCursor(0, IDC_ARROW);
    wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    wndclass.lpszMenuName  = MAKEINTRESOURCE(MAIN_MENU);
    wndclass.lpszClassName = className;
    wndclass.hIconSm       = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_NPICON),
                            IMAGE_ICON, 16, 16, 0);

    if (!RegisterClassEx(&wndclass)) return FALSE;

    /* Setup windows */

    monitor = MonitorFromRect( &Globals.main_rect, MONITOR_DEFAULTTOPRIMARY );
    info.cbSize = sizeof(info);
    GetMonitorInfoW( monitor, &info );

    x = Globals.main_rect.left;
    y = Globals.main_rect.top;
    if (Globals.main_rect.left >= info.rcWork.right ||
        Globals.main_rect.top >= info.rcWork.bottom ||
        Globals.main_rect.right < info.rcWork.left ||
        Globals.main_rect.bottom < info.rcWork.top)
        x = y = CW_USEDEFAULT;

    Globals.hMainWnd =
        CreateWindow(className, winName, WS_OVERLAPPEDWINDOW,
                     x, y, Globals.main_rect.right - Globals.main_rect.left,
                     Globals.main_rect.bottom - Globals.main_rect.top,
                     NULL, NULL, Globals.hInstance, NULL);
    if (!Globals.hMainWnd)
    {
        ShowLastError();
        ExitProcess(1);
    }

    DoCreateEditWindow();

    NOTEPAD_InitData();
    DIALOG_FileNew();

    ShowWindow(Globals.hMainWnd, show);
    UpdateWindow(Globals.hMainWnd);
    DragAcceptFiles(Globals.hMainWnd, TRUE);

    DIALOG_ViewStatusBar();

    HandleCommandLine(cmdline);

    hAccel = LoadAccelerators( hInstance, MAKEINTRESOURCE(ID_ACCEL) );

    while (GetMessage(&msg, 0, 0, 0))
    {
        if (!IsDialogMessage(Globals.hFindReplaceDlg, &msg) &&
            !TranslateAccelerator(Globals.hMainWnd, hAccel, &msg))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }
    return (int) msg.wParam;
}
示例#24
0
static void ui_window_win32_set_droppable(void *data, bool droppable)
{
   /* Minimum supported client: Windows XP, minimum supported server: Windows 2000 Server */
   ui_window_win32_t *window = (ui_window_win32_t*)data;
   DragAcceptFiles(window->hwnd, droppable);
}
示例#25
0
// Creates the GLFW window and rendering context
//
static GLFWbool createWindow(_GLFWwindow* window,
                             const _GLFWwndconfig* wndconfig,
                             const _GLFWctxconfig* ctxconfig,
                             const _GLFWfbconfig* fbconfig)
{
    int xpos, ypos, fullWidth, fullHeight;
    WCHAR* wideTitle;

    if (wndconfig->monitor)
    {
        GLFWvidmode mode;

        // NOTE: This window placement is temporary and approximate, as the
        //       correct position and size cannot be known until the monitor
        //       video mode has been set
        _glfwPlatformGetMonitorPos(wndconfig->monitor, &xpos, &ypos);
        _glfwPlatformGetVideoMode(wndconfig->monitor, &mode);
        fullWidth  = mode.width;
        fullHeight = mode.height;
    }
    else
    {
        xpos = CW_USEDEFAULT;
        ypos = CW_USEDEFAULT;

        getFullWindowSize(getWindowStyle(window), getWindowExStyle(window),
                          wndconfig->width, wndconfig->height,
                          &fullWidth, &fullHeight);
    }

    wideTitle = _glfwCreateWideStringFromUTF8(wndconfig->title);
    if (!wideTitle)
    {
        _glfwInputError(GLFW_PLATFORM_ERROR,
                        "Win32: Failed to convert window title to UTF-16");
        return GLFW_FALSE;
    }

    window->win32.handle = CreateWindowExW(getWindowExStyle(window),
                                           _GLFW_WNDCLASSNAME,
                                           wideTitle,
                                           getWindowStyle(window),
                                           xpos, ypos,
                                           fullWidth, fullHeight,
                                           NULL, // No parent window
                                           NULL, // No window menu
                                           GetModuleHandleW(NULL),
                                           window); // Pass object to WM_CREATE

    free(wideTitle);

    if (!window->win32.handle)
    {
        _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to create window");
        return GLFW_FALSE;
    }

    if (_glfw_ChangeWindowMessageFilterEx)
    {
        _glfw_ChangeWindowMessageFilterEx(window->win32.handle,
                                          WM_DROPFILES, MSGFLT_ALLOW, NULL);
        _glfw_ChangeWindowMessageFilterEx(window->win32.handle,
                                          WM_COPYDATA, MSGFLT_ALLOW, NULL);
        _glfw_ChangeWindowMessageFilterEx(window->win32.handle,
                                          WM_COPYGLOBALDATA, MSGFLT_ALLOW, NULL);
    }

    if (wndconfig->floating && !wndconfig->monitor)
    {
        SetWindowPos(window->win32.handle,
                     HWND_TOPMOST,
                     0, 0, 0, 0,
                     SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
    }

    DragAcceptFiles(window->win32.handle, TRUE);

    if (!_glfwCreateContext(window, ctxconfig, fbconfig))
        return GLFW_FALSE;

    window->win32.minwidth  = GLFW_DONT_CARE;
    window->win32.minheight = GLFW_DONT_CARE;
    window->win32.maxwidth  = GLFW_DONT_CARE;
    window->win32.maxheight = GLFW_DONT_CARE;
    window->win32.numer     = GLFW_DONT_CARE;
    window->win32.denom     = GLFW_DONT_CARE;

    return GLFW_TRUE;
}
示例#26
0
	BOOL Show(HINSTANCE hInstance, int nCmdShow)
	{
		hInst = hInstance; // Store instance handle in our global variable

		int zoom = g_Config.iWindowZoom;
		if (zoom < 1) zoom = 1;
		if (zoom > 4) zoom = 4;
		
		RECT rc, rcOrig;
		GetWindowRectAtZoom(zoom, rcOrig, rc);

		u32 style = WS_OVERLAPPEDWINDOW;

		hwndMain = CreateWindowEx(0,szWindowClass, "", style,
			rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, hInstance, NULL);
		if (!hwndMain)
			return FALSE;

		hwndDisplay = CreateWindowEx(0, szDisplayClass, TEXT(""), WS_CHILD | WS_VISIBLE,
			rcOrig.left, rcOrig.top, rcOrig.right - rcOrig.left, rcOrig.bottom - rcOrig.top, hwndMain, 0, hInstance, 0);
		if (!hwndDisplay)
			return FALSE;

		menu = GetMenu(hwndMain);
#ifdef FINAL
		RemoveMenu(menu,2,MF_BYPOSITION);
		RemoveMenu(menu,2,MF_BYPOSITION);
#endif
		MENUINFO info;
		ZeroMemory(&info,sizeof(MENUINFO));
		info.cbSize = sizeof(MENUINFO);
		info.cyMax = 0;
		info.dwStyle = MNS_CHECKORBMP;
		info.fMask = MIM_STYLE;
		for (int i = 0; i < GetMenuItemCount(menu); i++)
		{
			SetMenuInfo(GetSubMenu(menu,i),&info);
		}
		UpdateMenus();

		//accept dragged files
		DragAcceptFiles(hwndMain, TRUE);

		hideCursor = true;
		SetTimer(hwndMain, TIMER_CURSORUPDATE, CURSORUPDATE_INTERVAL_MS, 0);

		Update();
		SetPlaying(0);

		if(g_Config.bFullScreenOnLaunch)
			_ViewFullScreen(hwndMain);
		
		ShowWindow(hwndMain, nCmdShow);

		W32Util::MakeTopMost(hwndMain, g_Config.bTopMost);

#if ENABLE_TOUCH
		RegisterTouchWindow(hwndDisplay, TWF_WANTPALM);
#endif

		RAWINPUTDEVICE keyboard;
		memset(&keyboard, 0, sizeof(keyboard));
		keyboard.usUsagePage = 1;
		keyboard.usUsage = 6;
		keyboard.dwFlags = 0; // RIDEV_NOLEGACY | ;
		RegisterRawInputDevices(&keyboard, 1, sizeof(RAWINPUTDEVICE));

		SetFocus(hwndDisplay);

		return TRUE;
	}
示例#27
0
LRESULT CFolderInputDialog::WndProc(HWND window, UINT msg, WPARAM wp, LPARAM lp)
{
	static CButton btn_dir, btn_ok, btn_cancel;
	static CEditBox edit_dir;
	static CLabel label_dir;

	switch (msg)
	{
		case WM_INITDIALOG:
		{
			// Allow D&D (Drag & Drop)
			DragAcceptFiles(window, TRUE);

			UINT id = 10000;
			int x = 10;
			int y = -10;

			SetWindowText(window, _T("Select a destination"));

			label_dir.Create(window, _T("Input folder name"), id++, x, y += 20, 100, 20);
			edit_dir.Create(window, m_save_dir, id++, x, y += 20, 300, 22);
			btn_dir.Create(window, _T("Browse"), id++, x + 300, y + 1, 40, 20);

			btn_ok.Create(window, _T("OK"), IDOK, 110, y += 30, 70, 23);
			btn_cancel.Create(window, _T("Cancel"), IDCANCEL, 190, y, 70, 23);

			edit_dir.SetFocus();
			btn_ok.SetDef();

			Init(380, y + 60);

			return FALSE;
		}

		case WM_DROPFILES:
		{
			TCHAR save_dir[_MAX_DIR];
			HDROP drop = reinterpret_cast<HDROP>(wp);
			DragQueryFile(drop, 0, save_dir, sizeof(save_dir));
			edit_dir.SetText(save_dir);
			return FALSE;
		}

		case WM_COMMAND:

			//  Browse button is pressed
			if (LOWORD(wp) == btn_dir.GetID())
			{
				TCHAR save_dir[_MAX_DIR];
				lstrcpy(save_dir, m_save_dir);
				CFolderDialog folder_dialog;
				if (folder_dialog.DoModal(window, _T("Select a folder"), save_dir) == TRUE)
					edit_dir.SetText(save_dir);
				return FALSE;
			}

			// OK button is pressed
			if (LOWORD(wp) == IDOK)
			{
				edit_dir.GetText(m_save_dir, _MAX_DIR);
				PathRemoveBackslash(m_save_dir);
				EndDialog(window, IDOK);
				return TRUE;
			}

			// Cancel button is pressed
			if (LOWORD(wp) == IDCANCEL)
			{
				EndDialog(window, IDCANCEL);
				return TRUE;
			}

			return FALSE;
	}

	return FALSE;
}
示例#28
0
LRESULT CALLBACK SimulatorWin::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    if (!_instance) return 0;

    switch (uMsg)
    {
    case WM_COMMAND:
    {
        if (HIWORD(wParam) == 0)
        {
            // menu
            WORD menuId = LOWORD(wParam);
            PlayerMenuItemWin *menuItem = _instance->_menuService->getItemByCommandId(menuId);
            if (menuItem)
            {
                AppEvent event("APP.EVENT", APP_EVENT_MENU);

                std::stringstream buf;
                buf << "{\"data\":\"" << menuItem->getMenuId().c_str() << "\"";
                buf << ",\"name\":" << "\"menuClicked\"" << "}";
                event.setDataString(buf.str());
                event.setUserData(menuItem);
                Director::getInstance()->getEventDispatcher()->dispatchEvent(&event);
            }

            if (menuId == ID_HELP_ABOUT)
            {
                onHelpAbout();
            }
        }
        break;
    }
    case WM_KEYDOWN:
    {
        if (wParam == VK_F5)
        {
            PlayerProtocol::getInstance()->relaunch();
        }
        break;
    }

    case WM_COPYDATA:
        {
            PCOPYDATASTRUCT pMyCDS = (PCOPYDATASTRUCT) lParam;
            if (pMyCDS->dwData == 1)
            {
                const char *szBuf = (const char*)(pMyCDS->lpData);
                SimulatorWin::getInstance()->writeDebugLog(szBuf);
                break;
            }
        }

    case WM_DESTROY:
    {
        DragAcceptFiles(hWnd, FALSE);
        break;
    }

    case WM_DROPFILES:
    {
        HDROP hDrop = (HDROP)wParam;

        const int count = DragQueryFileW(hDrop, 0xffffffff, NULL, 0);
        
        if (count > 0)
        {
            int fileIndex = 0;

            const UINT length = DragQueryFileW(hDrop, fileIndex, NULL, 0);
            WCHAR* buffer = (WCHAR*)calloc(length + 1, sizeof(WCHAR));

            DragQueryFileW(hDrop, fileIndex, buffer, length + 1);
            char *utf8 = SimulatorWin::convertTCharToUtf8(buffer);
            std::string firstFile(utf8);
            CC_SAFE_FREE(utf8);
            DragFinish(hDrop);

            // broadcast drop event
            AppEvent forwardEvent("APP.EVENT.DROP", APP_EVENT_DROP);
            forwardEvent.setDataString(firstFile);

            Director::getInstance()->getEventDispatcher()->dispatchEvent(&forwardEvent);
        }
    }   // WM_DROPFILES

    }
    return g_oldWindowProc(hWnd, uMsg, wParam, lParam);
}
示例#29
0
int SimulatorWin::run()
{
    auto player = player::PlayerWin::create();

    INITCOMMONCONTROLSEX InitCtrls;
    InitCtrls.dwSize = sizeof(InitCtrls);
    InitCtrls.dwICC = ICC_WIN95_CLASSES;
    InitCommonControlsEx(&InitCtrls);

    parseCocosProjectConfig(_project);

    // load project config from command line args
    vector<string> args;
    for (int i = 0; i < __argc; ++i)
    {
        wstring ws(__wargv[i]);
        string s;
        s.assign(ws.begin(), ws.end());
        args.push_back(s);
    }
    _project.parseCommandLine(args);

    if (_project.getProjectDir().empty())
    {
        if (args.size() == 2)
        {
            // for Code IDE before RC2
            _project.setProjectDir(args.at(1));
            _project.setDebuggerType(kCCRuntimeDebuggerCodeIDE);
        }
    }

    // create the application instance
    _app = new AppDelegate();
    _app->setProjectConfig(_project);

    // create console window
    if (_project.isShowConsole())
    {
        AllocConsole();
        _hwndConsole = GetConsoleWindow();
        if (_hwndConsole != NULL)
        {
            ShowWindow(_hwndConsole, SW_SHOW);
            BringWindowToTop(_hwndConsole);
            freopen("CONOUT$", "wt", stdout);
            freopen("CONOUT$", "wt", stderr);

            HMENU hmenu = GetSystemMenu(_hwndConsole, FALSE);
            if (hmenu != NULL)
            {
                DeleteMenu(hmenu, SC_CLOSE, MF_BYCOMMAND);
            }
        }
    }

    // log file
    if (_project.isWriteDebugLogToFile())
    {
        const string debugLogFilePath = _project.getDebugLogFilePath();
        _writeDebugLogFile = fopen(debugLogFilePath.c_str(), "w");
        if (!_writeDebugLogFile)
        {
            CCLOG("Cannot create debug log file %s", debugLogFilePath.c_str());
        }
    }

    // set environments
    SetCurrentDirectoryA(_project.getProjectDir().c_str());
    FileUtils::getInstance()->setDefaultResourceRootPath(_project.getProjectDir());
    FileUtils::getInstance()->setWritablePath(_project.getWritableRealPath().c_str());

    // check screen DPI
    HDC screen = GetDC(0);
    int dpi = GetDeviceCaps(screen, LOGPIXELSX);
    ReleaseDC(0, screen);

    // set scale with DPI
    //  96 DPI = 100 % scaling
    // 120 DPI = 125 % scaling
    // 144 DPI = 150 % scaling
    // 192 DPI = 200 % scaling
    // http://msdn.microsoft.com/en-us/library/windows/desktop/dn469266%28v=vs.85%29.aspx#dpi_and_the_desktop_scaling_factor
    //
    // enable DPI-Aware with DeclareDPIAware.manifest
    // http://msdn.microsoft.com/en-us/library/windows/desktop/dn469266%28v=vs.85%29.aspx#declaring_dpi_awareness
    float screenScale = 1.0f;
    if (dpi >= 120 && dpi < 144)
    {
        screenScale = 1.25f;
    }
    else if (dpi >= 144 && dpi < 192)
    {
        screenScale = 1.5f;
    }
    else if (dpi >= 192)
    {
        screenScale = 2.0f;
    }
    CCLOG("SCREEN DPI = %d, SCREEN SCALE = %0.2f", dpi, screenScale);

    // create opengl view
    Size frameSize = _project.getFrameSize();
    float frameScale = 1.0f;
    if (_project.isRetinaDisplay())
    {
        frameSize.width *= screenScale;
        frameSize.height *= screenScale;
    }
    else
    {
        frameScale = screenScale;
    }

    const Rect frameRect = Rect(0, 0, frameSize.width, frameSize.height);
    const bool isResize = _project.isResizeWindow();
    std::stringstream title;
    title << "Cocos Simulator - " << ConfigParser::getInstance()->getInitViewName();
    initGLContextAttrs();
    auto glview = GLViewImpl::createWithRect(title.str(), frameRect, frameScale);
    _hwnd = glview->getWin32Window();
    DragAcceptFiles(_hwnd, TRUE);
    //SendMessage(_hwnd, WM_SETICON, ICON_BIG, (LPARAM)icon);
    //SendMessage(_hwnd, WM_SETICON, ICON_SMALL, (LPARAM)icon);
    //FreeResource(icon);

    auto director = Director::getInstance();
    director->setOpenGLView(glview);

    director->setAnimationInterval(1.0 / 60.0);

    // set window position
    if (_project.getProjectDir().length())
    {
        setZoom(_project.getFrameScale()); 
    }
    Vec2 pos = _project.getWindowOffset();
    if (pos.x != 0 && pos.y != 0)
    {
        RECT rect;
        GetWindowRect(_hwnd, &rect);
        MoveWindow(_hwnd, pos.x, pos.y, rect.right - rect.left, rect.bottom - rect.top, FALSE);
    }

    // path for looking Lang file, Studio Default images
    FileUtils::getInstance()->addSearchPath(getApplicationPath().c_str());

    // init player services
    initServices();
    setupUI();
    DrawMenuBar(_hwnd);

    // prepare
    FileUtils::getInstance()->setPopupNotify(false);
    _project.dump();
    auto app = Application::getInstance();

    g_oldWindowProc = (WNDPROC)SetWindowLong(_hwnd, GWL_WNDPROC, (LONG)SimulatorWin::windowProc);

    // update window size
    RECT rect;
    GetWindowRect(_hwnd, &rect);
    MoveWindow(_hwnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top + GetSystemMetrics(SM_CYMENU), FALSE);

    // startup message loop
    return app->run();
}
示例#30
0
文件: MainFrm.cpp 项目: pdrezet/brix
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;

	DragAcceptFiles(true);

	EnableDocking( CBRS_ALIGN_TOP);
	EnableDocking( CBRS_ALIGN_RIGHT);
	EnableDocking( CBRS_ALIGN_LEFT);
	EnableDocking( CBRS_ALIGN_BOTTOM);

 UINT assignedToolbarID = 3344500;
 DWORD style = WS_CHILD | WS_VISIBLE | CBRS_TOP |
  CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC;
 if( !m_wndToolBar.CreateEx( this, TBSTYLE_FLAT, style, INXRect(1, 1, 1, 1), assignedToolbarID) )
  return -1;
 if( !m_wndToolBar.LoadToolBar( IDR_MAINFRAME ) )
  return -1;

/*
	if (!m_wndToolBar.Create(this) ||
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}
*/

/* old toolbar method for 4bit colour toolbar
HBITMAP hBitmap = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(),
    MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_BITMAP,
    0,0, LR_CREATEDIBSECTION | LR_LOADMAP3DCOLORS);
CBitmap bm;
bm.Attach(hBitmap);
*/

// toolbar bitmap is comprosed of a strip of 16wx15h images for each button - for example if there are 30 buttons on the toolbar, the toolbar bitmap will be 30x16=480 pixels wide
//standard image size for mfc toolbar is 16wx15h
//int toolButtonHeight = 15;
//int toolButtonWidth = 16;
int toolButtonHeight = 24;
int toolButtonWidth = 24;
m_wndToolBar.SetSizes(INXSize(toolButtonWidth + 7, toolButtonHeight + 6), INXSize(toolButtonWidth, toolButtonHeight)); // NOTE - will fail unless button is bigger than image, +7 pixels w and +6 pixels h

#ifndef TOOLBAR_32BitRGBA

// use IDR_MAINFRAME Toolbar_24bit.bmp or Toolbar_16bit.bmp in DrawProg.rc

// create a toolbar using the imagelist
CImageList *m_imagelist = new CImageList;
HBITMAP hbm = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),
   MAKEINTRESOURCE(IDR_MAINFRAME),
   IMAGE_BITMAP,
   0,0, // cx, cy
   LR_CREATEDIBSECTION | LR_LOADMAP3DCOLORS );
CBitmap bm;
bm.Attach(hbm);

m_imagelist->Create(toolButtonWidth,toolButtonHeight,ILC_COLOR24|ILC_MASK,1,1); //24bit colour with colour mask
//m_imagelist->Create(toolButtonWidth,toolButtonHeight,ILC_COLOR16|ILC_MASK,1,1); //16bit colour with colour mask
m_imagelist->Add(&bm, RGB(215,215,215)); // back colour of Toolbar_24bit.bmp and Toolbar_16bit.bmp to use as colour mask
m_wndToolBar.GetToolBarCtrl().SetImageList(m_imagelist);
//m_wndToolBar.GetToolBarCtrl().SetDisabledImageList(m_imagelist);  // don't need this as mfc greys out buttons by default but if you want to design the images for disabled buttons, create an image list and add it here

#else 

// use IDR_MAINFRAME Toolbar_32bit.bmp in DrawProg.rc

// - this only works for machines with 32-bit colour depth, otherwise get black background
// but still have a problem where there is a dark background colour to each button in wine
// this may be the way the image is created in GIMP, some problem with the alpha channel
CImageList *m_imagelist = new CImageList;
HBITMAP hbm = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),
   MAKEINTRESOURCE(IDR_MAINFRAME),
   IMAGE_BITMAP,
   0,0, // cx, cy
   LR_CREATEDIBSECTION);
CBitmap bm;
bm.Attach(hbm);

m_imagelist->Create(toolButtonWidth,toolButtonHeight,ILC_COLOR32,1,1); // no colour mask with alpha transparency
m_imagelist->Add(&bm, (CBitmap*)NULL);
m_wndToolBar.GetToolBarCtrl().SetImageList(m_imagelist);
//@todo - create a diabled image list. When using 32bit RGBA need a disabled image list, as mfc can't create greyed out icons as no colour mask
//m_wndToolBar.GetToolBarCtrl().SetDisabledImageList(m_imagelist);

#endif //TOOLBAR_32BitRGBA

	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}


	// set width of pane and remove border
	m_wndStatusBar.SetPaneInfo(m_wndStatusBar.CommandToIndex(ID_INDICATOR_LOCALHOST),ID_INDICATOR_LOCALHOST, SBPS_NOBORDERS, 14);
	m_wndStatusBar.SetPaneInfo(m_wndStatusBar.CommandToIndex(ID_INDICATOR_NUM),ID_INDICATOR_NUM, SBPS_NOBORDERS, 14);
	m_wndStatusBar.SetPaneInfo(m_wndStatusBar.CommandToIndex(ID_INDICATOR_CAPS),ID_INDICATOR_CAPS, SBPS_NOBORDERS, 84);
	m_wndStatusBar.SetPaneInfo(m_wndStatusBar.CommandToIndex(ID_INDICATOR_SCRL),ID_INDICATOR_SCRL, SBPS_NOBORDERS, 84);


	INXRect rect;
	int nIndex = m_wndToolBar.GetToolBarCtrl().CommandToIndex(ID_EHS_HOST_COMBO);
	m_wndToolBar.SetButtonInfo(nIndex, ID_EHS_HOST_COMBO, TBBS_SEPARATOR, 110); // this sets the width and makes it a separator type - may need to change back to button type if want to work with larger toolbar buttons 32x32
	m_wndToolBar.GetToolBarCtrl().GetItemRect(nIndex, (LPRECT)rect);
	rect.top = 4; // added y-offset for 24x24 toolbar
	rect.bottom = rect.top + 250 /*drop height*/;
	if(!m_combo.Create(CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_VISIBLE |
		WS_TABSTOP | WS_VSCROLL, rect, &m_wndToolBar, ID_EHS_HOST_COMBO))
	{
		TRACE(_T("Failed to create combo-box\n"));
		return FALSE;
	}
	m_combo.AddString(TARGET_DISPLAY_NAME_LOCAL);
	m_combo.AddString(TARGET_DISPLAY_NAME_REMOTE);
	m_combo.AddString(TARGET_DISPLAY_NAME_APPSERVER);
	CFont *m_Font = m_wndStatusBar.GetFont();
	m_combo.SetFont(m_Font);




	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndToolBar);


	m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
		CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

	
	// create project bar

	if (!m_wndProjectBar.Create(_T(""), this, 123))
	{
		TRACE0("Failed to create project bar\n");
		return -1;		// fail to create
	}

	m_wndProjectBar.SetBarStyle(m_wndProjectBar.GetBarStyle() |
		CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

	m_wndProjectBar.SetSCBStyle(m_wndProjectBar.GetSCBStyle() | SCBS_SIZECHILD);

	m_wndProjectBar.SetWindowTextA( _T("Project Bar") );

	m_wndProjectBar.EnableDocking(CBRS_ALIGN_ANY);

	DockControlBar(&m_wndProjectBar, AFX_IDW_DOCKBAR_RIGHT);

	m_wndProjectBar.init();


	if (!m_cFuncBlockBar.Create("FuncBlockBar", this, 123 ))
	{
		TRACE0("Failed to create project FncBlkBar\n");
		return -1;		// fail to create
	}

	m_cFuncBlockBar.SetBarStyle(m_cFuncBlockBar.GetBarStyle() |
		CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

	m_cFuncBlockBar.SetSCBStyle(m_cFuncBlockBar.GetSCBStyle() |SCBS_SIZECHILD);

	m_cFuncBlockBar.EnableDocking(CBRS_ALIGN_ANY);

	DockControlBar(&m_cFuncBlockBar, AFX_IDW_DOCKBAR_LEFT);

	m_cFuncBlockBar.init();

	return 0;
}