Пример #1
1
static void cdcreatecanvas(cdCanvas* canvas, void *data)
{
  cdCtxCanvas* ctxcanvas;
  cairo_surface_t *surface;

  HWND hWnd = (HWND)data;
  HDC ScreenDC, hDC;
  HRGN clip_hrgn;

  ScreenDC = GetDC(NULL);
  canvas->bpp = GetDeviceCaps(ScreenDC, BITSPIXEL);
  canvas->xres = (float)(((double)GetDeviceCaps(ScreenDC, LOGPIXELSX)) / 25.4);
  canvas->yres = (float)(((double)GetDeviceCaps(ScreenDC, LOGPIXELSY)) / 25.4);
  ReleaseDC(NULL, ScreenDC);

  if (!data)
  {
    hDC = GetDC(NULL);
    canvas->w = GetDeviceCaps(hDC, HORZRES);
    canvas->h = GetDeviceCaps(hDC, VERTRES);
  }
  else 
  {
    RECT rect;
    hWnd = (HWND)data;

    hDC = GetDC(hWnd);
  
    GetClientRect(hWnd, &rect);
    canvas->w = rect.right - rect.left;
    canvas->h = rect.bottom - rect.top;
  }

  /* initial clip extents controls size */
  clip_hrgn = CreateRectRgn(0, 0, canvas->w, canvas->h);
  SelectClipRgn(hDC, clip_hrgn);
  DeleteObject(clip_hrgn);

  surface = cairo_win32_surface_create(hDC);

  canvas->w_mm = ((double)canvas->w) / canvas->xres;
  canvas->h_mm = ((double)canvas->h) / canvas->yres;

  ctxcanvas = cdcairoCreateCanvas(canvas, cairo_create(surface));
  cairo_surface_destroy(surface);

  ctxcanvas->hDC = hDC;
  ctxcanvas->hWnd = hWnd;

  if (hWnd)
  {
    LONG style = GetClassLong(hWnd, GCL_STYLE);
    ctxcanvas->isOwnedDC = (int) ((style & CS_OWNDC) || (style & CS_CLASSDC));
  }
  else
    ctxcanvas->isOwnedDC = 1;
}
Пример #2
0
HICON get_window_icon_big(HWND hwnd, bool allow_from_class)
{
	HICON hIcon = 0;

	SendMessageTimeout(hwnd, WM_GETICON, ICON_BIG, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&hIcon);

	if (!hIcon)
		SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL2, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&hIcon);

	if (!hIcon)
		SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&hIcon);

	if (allow_from_class) {
		if (!hIcon)
			hIcon = (HICON)GetClassLong(hwnd, GCL_HICON);

		if (!hIcon)
			hIcon = (HICON)GetClassLong(hwnd, GCL_HICONSM);
	}

	if (!hIcon)
		SendMessageTimeout(hwnd, WM_QUERYDRAGICON, 0, 0, 0, 1000, (LPDWORD)&hIcon);

	return hIcon;
}
Пример #3
0
void CSizingControlBar::OnNcPaint()
{
    // get window DC that is clipped to the non-client area
    CWindowDC dc(this);

    CRect rcClient, rcBar;
    GetClientRect(rcClient);
    ClientToScreen(rcClient);
    GetWindowRect(rcBar);
    rcClient.OffsetRect(-rcBar.TopLeft());
    rcBar.OffsetRect(-rcBar.TopLeft());

    CDC mdc;
    mdc.CreateCompatibleDC(&dc);
    
    CBitmap bm;
    bm.CreateCompatibleBitmap(&dc, rcBar.Width(), rcBar.Height());
    CBitmap* pOldBm = mdc.SelectObject(&bm);

    // draw borders in non-client area
    CRect rcDraw = rcBar;
    DrawBorders(&mdc, rcDraw);

    // erase the NC background
#ifdef _WIN64
    mdc.FillRect(rcDraw, CBrush::FromHandle(
        (HBRUSH) GetClassLong(m_hWnd, GCLP_HBRBACKGROUND)));
#else
    mdc.FillRect(rcDraw, CBrush::FromHandle(
        (HBRUSH) GetClassLong(m_hWnd, GCL_HBRBACKGROUND)));
#endif

    if (m_dwSCBStyle & SCBS_SHOWEDGES)
    {
        CRect rcEdge; // paint the sizing edges
        for (int i = 0; i < 4; i++)
            if (GetEdgeRect(rcBar, GetEdgeHTCode(i), rcEdge))
                mdc.Draw3dRect(rcEdge, ::GetSysColor(COLOR_BTNHIGHLIGHT),
                    ::GetSysColor(COLOR_BTNSHADOW));
    }

    NcPaintGripper(&mdc, rcClient);

    // client area is not our bussiness :)
    dc.IntersectClipRect(rcBar);
    dc.ExcludeClipRect(rcClient);

    dc.BitBlt(0, 0, rcBar.Width(), rcBar.Height(), &mdc, 0, 0, SRCCOPY);

    ReleaseDC(&dc);

    mdc.SelectObject(pOldBm);
    bm.DeleteObject();
    mdc.DeleteDC();
}
void CTaskSwitcher32Dlg::FilterList()
{
	m_windowList2.DeleteAllItems();

	window_list *list = window_item::get_window_list();
	CImageList *pImageList = new CImageList(); pImageList->Create( 16, 16, ILC_COLOR32 | ILC_MASK | ILC_PERITEMMIRROR, 0, 10);

	m_windowList2.SetImageList( pImageList, LVSIL_SMALL);
	int default_idx = pImageList->Add( m_hIcon );
		
	for ( unsigned int i = 0; i < list->size(); i++ )
	{
		window_item *item = (*list)[i];
		bool ok = true;
		if ( this->search.length() > 0 )
		{
			int pos = item->get_lower_title().find( this->search ) ; 
			int pos2 = item->get_process_name().find( this->search );
			if ( pos == std::string::npos && pos2 == std::string::npos ) 
				ok = false;
		}
		if ( ok )
		{
			HWND hwnd = item->get_handle();
			HICON hIcon = NULL;
 
			SendMessageTimeout(hwnd, WM_GETICON, ICON_BIG, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&hIcon);
			if (!hIcon) SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL2, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&hIcon);
 			if (!hIcon) SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&hIcon);
            if (!hIcon) hIcon = (HICON)GetClassLong(hwnd, GCL_HICON);
            if (!hIcon) hIcon = (HICON)GetClassLong(hwnd, GCL_HICONSM);
        
		
			int imageidx = -1;
			if ( hIcon != NULL )
			{
				HICON iconCopy = CopyIcon( hIcon );				
				imageidx = pImageList->Add( iconCopy );
				DestroyIcon( iconCopy );
			}
			else
			{
				imageidx = 1;
			}
			int idx = m_windowList2.InsertItem( 0, item->get_title().c_str(), imageidx );
			m_windowList2.SetItem(  idx, 1, LVIF_TEXT | LVIF_IMAGE, item->get_process_name().c_str(), imageidx, 0, 0, 0 );
			m_windowList2.SetItemData( idx, (DWORD_PTR) item );
			
		}
	}
	m_windowList2.SetItemState( 0, LVIS_SELECTED, LVIS_SELECTED );
	m_windowList2.SetSelectionMark( 0 );

}
Пример #5
0
 ///////////////////////////////////////////////////////////////////////
 ///  Function: WindowClassProc
 ///
 ///    Author: $author$
 ///      Date: 4/6/2012
 ///////////////////////////////////////////////////////////////////////
 static LRESULT CALLBACK WindowClassProc
 (HWND hWnd,
  UINT msg,
  WPARAM wParam,
  LPARAM lParam) 
 {
     LRESULT lResult = 0;
     XosWinWindow* target = 0;
     WNDPROC windowSubclassProc = 0;
     DWORD wndExtra;
     DWORD wndIndex;
     DWORD wndClassExtra;
     DWORD wndClassIndex;
     
     if (sizeof(XosWinWindow*) <= (wndExtra = GetClassLong(hWnd, GCL_CBWNDEXTRA)))
     if (0 <= (wndIndex = wndExtra-sizeof(XosWinWindow*)))
     if ((target = (XosWinWindow*)(GetWindowLongPtr(hWnd, wndIndex))))
     {
         lResult = target->OnWindowMessage(hWnd, msg, wParam, lParam);
         return lResult;
     }
     else
     if ((WM_NCCREATE == msg))
     {
         CREATESTRUCT* cs;
         if ((cs = (CREATESTRUCT*)(lParam)))
         if ((target = (XosWinWindow*)(cs->lpCreateParams)))
         if (sizeof(windowSubclassProc) <= (wndClassExtra = GetClassLong(hWnd, GCL_CBCLSEXTRA)))
         if (0 <= (wndClassIndex = wndClassExtra-sizeof(windowSubclassProc)))
         if ((windowSubclassProc = (WNDPROC)(GetClassLongPtr(hWnd, wndClassIndex))))
         {
             SetWindowLongPtr(hWnd, wndIndex, (LONG_PTR)(target));
             if (!(target->Attached())) target->Attach(hWnd);
             lResult = target->OnWindowMessage(hWnd, msg, wParam, lParam);
             return lResult;
         }
     }
     
     if (sizeof(windowSubclassProc) <= (wndClassExtra = GetClassLong(hWnd, GCL_CBCLSEXTRA)))
     if (0 <= (wndClassIndex = wndClassExtra-sizeof(windowSubclassProc)))
         windowSubclassProc = (WNDPROC)(GetClassLongPtr(hWnd, wndClassIndex));
     
     if (windowSubclassProc)
         lResult = CallWindowProc
         (windowSubclassProc, hWnd, msg, wParam, lParam);
     else
     lResult = DefWindowProc(hWnd, msg, wParam, lParam);
     return lResult;
 }
Пример #6
0
BOOL CSkinDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();
	//产生阴影
	SetClassLong(this->m_hWnd, GCL_STYLE, GetClassLong(this->m_hWnd, GCL_STYLE) | CS_DROPSHADOW);

	// 设置此对话框的图标。  当应用程序主窗口不是对话框时,框架将自动
	//  执行此操作
	SetIcon(m_hIcon, TRUE);			// 设置大图标
	SetIcon(m_hIcon, FALSE);		// 设置小图标

	// TODO:  在此添加额外的初始化代码
	m_btnOK.Load(IDB_Button, 86);
	m_btnCancel.Load(IDB_Button, 86);
	m_btnClose.Load(IDB_Close, 39);
	m_btnClose.SetAutoSize(FALSE);
	m_btnMini.Load(IDB_Mini, 28);
	m_btnMini.SetAutoSize(FALSE);
	CRect rcEdit;
	m_edt1.GetWindowRect(&rcEdit);
	ScreenToClient(&rcEdit);
	m_edt1.MoveWindow(rcEdit.left, rcEdit.top, rcEdit.Width(), rcEdit.Height() + 1);
	m_edt1.MoveWindow(rcEdit.left, rcEdit.top, rcEdit.Width(), rcEdit.Height() - 1);
	// m_Edit1 不设置其他属性,让它保持类默认,一切属性都是在类中初始化好了的
	m_edt1.SetWindowText(_T("没有雅黑你怎么办呢?"));
	return TRUE;  // 除非将焦点设置到控件,否则返回 TRUE
}
Пример #7
0
/* sys_directx_set_close_button_callback:
 *  Sets the close button callback function.
 */
static int sys_directx_set_close_button_callback(void (*proc)(void))
{
    DWORD class_style;
    HMENU sys_menu;
    HWND allegro_wnd = win_get_window();

    user_close_proc = proc;

    /* get the old class style */
    class_style = GetClassLong(allegro_wnd, GCL_STYLE);

    /* and the system menu handle */
    sys_menu = GetSystemMenu(allegro_wnd, FALSE);

    /* enable or disable the no_close_button flag and the close menu option */
    if (proc) {
        class_style &= ~CS_NOCLOSE;
        EnableMenuItem(sys_menu, SC_CLOSE, MF_BYCOMMAND | MF_ENABLED);
    }
    else {
        class_style |= CS_NOCLOSE;
        EnableMenuItem(sys_menu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
    }

    /* change the class to the new style */
    SetClassLong(allegro_wnd, GCL_STYLE, class_style);

    /* Redraw the whole window to display the changes of the button.
     * (we use this because UpdateWindow() only works for the client area)
     */
    RedrawWindow(allegro_wnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW);

    return 0;
}
Пример #8
0
/**************************************************************************
...
**************************************************************************/
static void refresh_happiness_bitmap(HBITMAP bmp,
				     struct city *pcity,
				     enum citizen_feeling index)
{
  enum citizen_category citizens[MAX_CITY_SIZE];
  RECT rc;
  int i;
  int num_citizens = get_city_citizen_types(pcity, index, citizens);
  int pix_width = HAPPINESS_PIX_WIDTH * tileset_small_sprite_width(tileset);
  int offset = MIN(tileset_small_sprite_width(tileset), pix_width / num_citizens);
  /* int true_pix_width = (num_citizens - 1) * offset + tileset_small_sprite_width(tileset); */
  HDC hdc = CreateCompatibleDC(NULL);
  HBITMAP old=SelectObject(hdc,bmp);

  rc.left=0;
  rc.top=0;
  rc.right=pix_width;
  rc.bottom=tileset_small_sprite_height(tileset);
  FillRect(hdc,&rc,(HBRUSH)GetClassLong(root_window,GCL_HBRBACKGROUND));

  for (i = 0; i < num_citizens; i++) {
    draw_sprite(get_citizen_sprite(tileset, citizens[i], i, pcity),
		hdc, i * offset, 0);
  }

  SelectObject(hdc,old);
  DeleteDC(hdc);
}
Пример #9
0
int CAnsiWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
    SetClassLong(GetSafeHwnd(), GCL_STYLE, GetClassLong(GetSafeHwnd(), GCL_STYLE)-CS_VREDRAW);
    while ( m_strList.GetCount () < pDoc->m_nScrollSize ) 
        m_strList.AddTail("");

    // Init colors 
    m_nCurrentBg = 0;
    m_nCurrentFg =7;
    

//===================================================================================================================

    ((CMainFrame*)AfxGetMainWnd())->m_editBar.GetDlgItem(IDC_EDIT)->SetFont(&pDoc->m_fntText);

    CRect rect;
    GetClientRect(&rect);

    // To init screen dimentions in characters !!!
    
    SetScrollSettings();
    return 0;
}
Пример #10
0
VOID ShowNotifyIcon(HWND hWnd, BOOL bAdd)
{
	NOTIFYICONDATA nid;
	ZeroMemory(&nid,sizeof(nid));
	nid.cbSize=sizeof(NOTIFYICONDATA);
	nid.hWnd=hWnd;
	nid.uID=0;
	nid.uFlags=NIF_ICON | NIF_MESSAGE | NIF_TIP;
	nid.uCallbackMessage=WM_TRAYMESSAGE;
	nid.hIcon = (HICON)GetClassLong(hWnd, GCL_HICONSM);
	nid.uVersion = 0;
	GetWindowText(hWnd, nid.szTip, sizeof(nid.szTip));
	wcscat_s(nid.szTip, sizeof(nid.szTip), L"\nDouble-click to maximize");

	if(bAdd)
	{
		for(int i = 0; i < 60; i++)
		{
			if(Shell_NotifyIcon(NIM_ADD, &nid))
				break;

			Sleep(1000);
		}
	}
	else
		Shell_NotifyIcon(NIM_DELETE, &nid);
}
Пример #11
0
static HICON
get_icon(HWND hwnd, int large)
{
	HICON icon;

	if (!SendMessageTimeout(hwnd, WM_GETICON, large ? ICON_BIG : ICON_SMALL,
				0, SMTO_ABORTIFHUNG, 1000, (PDWORD_PTR) & icon))
		return NULL;

	if (icon)
		return icon;

	/*
	 * Modern versions of Windows uses the voodoo value of 2 instead of 0
	 * for the small icons.
	 */
	if (!large)
	{
		if (!SendMessageTimeout(hwnd, WM_GETICON, 2,
					0, SMTO_ABORTIFHUNG, 1000, (PDWORD_PTR) & icon))
			return NULL;
	}

	if (icon)
		return icon;

	icon = (HICON) GetClassLong(hwnd, large ? GCL_HICON : GCL_HICONSM);

	if (icon)
		return icon;

	return NULL;
}
Пример #12
0
int CAnsiWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
    SetClassLong(GetSafeHwnd(), GCL_STYLE, GetClassLong(GetSafeHwnd(), GCL_STYLE)-CS_VREDRAW);
    while ( m_strList.GetCount () < nScrollSize ) 
        m_strList.AddTail("");

	m_TotalLinesReceived = 0;

    // Init colors 
    m_nCurrentBg = 0;
    m_nCurrentFg =7;
    

//===================================================================================================================

    CRect rect;
    GetClientRect(&rect);

    // To init screen dimentions in characters !!!
    
    SetScrollSettings();
    return 0;
}
Пример #13
0
    ///////////////////////////////////////////////////////////////////////
    ///  Function: DialogWindow
    ///
    ///    Author: $author$
    ///      Date: 1/29/2012
    ///////////////////////////////////////////////////////////////////////
    static XosWinDialogWindow* DialogWindow
    (HWND hWnd,
     UINT msg,
     WPARAM wParam,
     LPARAM lParam) 
    {
        int wndExtra = GetClassLong(hWnd, GCL_CBWNDEXTRA);

        if (wndExtra < XosWinDialogWindowClass::WindowExtra())
            return 0;

        int wndExtraOffset = XosWinDialogWindowClass::WindowExtraOffset();

        XosWinDialogWindow* dialogWindow = (XosWinDialogWindow*)
        (GetWindowLongPtr(hWnd, wndExtraOffset));

        switch(msg)
        {
        case WM_INITDIALOG:
            SetWindowLongPtr(hWnd, wndExtraOffset, lParam);

            if ((dialogWindow = (XosWinDialogWindow*)(lParam)))
                dialogWindow->Attach(hWnd);
            break;

        case WM_DESTROY:
            SetWindowLongPtr(hWnd, wndExtraOffset, 0);
            break;
        }
        return dialogWindow;
    }
Пример #14
0
extern "C" __declspec(dllexport) LRESULT CALLBACK PoeWndProc(int nCode, WPARAM wParam, LPARAM lParam) {


	PCWPSTRUCT msg = (PCWPSTRUCT)lParam;
	
	if (origCursor == 0) {
		origCursor = (HCURSOR)GetClassLong(msg->hwnd,GCL_HCURSOR);
	}

	if (nCode < 0) {
		return CallNextHookEx(NULL,nCode,wParam,lParam);
	}

	if (msg->message == windowMessage) {
		// time to do magic and stuff.
		numPulses = 0;
		currentCursor = 0;

		SetClassLong(msg->hwnd, GCL_HCURSOR,(LONG)cursors[currentCursor]);
		SetCursor(cursors[currentCursor]);

		SetTimer(msg->hwnd,PULSE_TIMER,100,TimerProc);
		return TRUE;
	}

	return CallNextHookEx(NULL,nCode,wParam,lParam);
}
Пример #15
0
/* ボタンコントロール作成 */
HWND ButtonControl::CreateButton(
	LPCWSTR lpszText,
	LPRECT lpRect,
	HWND hWndParent,     // 親ウィンドウまたはオーナーウィンドウのハンドル
	HMENU hMenu,         // メニューハンドルまたは子ウィンドウ ID
	HINSTANCE hInstance, // アプリケーションインスタンスのハンドル
	int nNorm,           // ノーマルのときのリソースビットマップID
	int nSel,            // 押したときのリソースビットマップID
	int nHover,          // ホバーのときのリソースビットマップID
	int nDis             // ディセーブルのときのリソースビットマップID
	)
{
	m_hBmpNorm = LoadBitmap(hInstance, MAKEINTRESOURCE(nNorm));
	m_hBmpSel = LoadBitmap(hInstance, MAKEINTRESOURCE(nSel));
	m_hBmpHover = LoadBitmap(hInstance, MAKEINTRESOURCE(nHover));
	m_hBmpDis = LoadBitmap(hInstance, MAKEINTRESOURCE(nDis));
	m_nWidth = lpRect->right - lpRect->left;
	m_nHeight = lpRect->bottom - lpRect->top;
	const HWND hWnd = CreateWindowEx(0, L"BUTTON", lpszText, WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, lpRect->left, lpRect->top, m_nWidth, m_nHeight, hWndParent, hMenu, hInstance, NULL);
	if (!hWnd) return NULL;
	SetClassLong(hWnd, GCL_STYLE, GetClassLong(hWnd, GCL_STYLE) & ~CS_DBLCLKS);
	SetProp(hWnd, SZCECOWIZBUTTONPROC, this); // ウィンドウハンドルのプロパテにオブジェクトのポインタを関連付ける
	m_DefBtnProc = (WNDPROC)SetWindowLong(hWnd, GWL_WNDPROC, (LONG)GlobalButtonProc);
	return hWnd;
}
Пример #16
0
BOOL CDetailCustomDlg::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();

	DWORD style = GetClassLong(m_lstOptions, GCL_STYLE);
	SetClassLong(m_lstOptions, GCL_STYLE, style & ~CS_DBLCLKS);
	
	IcqContact *contact = ((CViewDetailDlg *) GetParent())->contact;
	bitset<NR_CONTACT_FLAGS> &f = contact->flags;
	for (int id = IDS_OPTION_FIRST; id <= IDS_OPTION_LAST; id++) {
		CString str;
		str.LoadString(id);
		int i = m_lstOptions.AddString(str);
		m_lstOptions.SetCheck(i, f.test(i));
	}
	CheckDlgButton(IDC_CUSTOM_SOUND, contact->flags.test(CF_CUSTOMSOUND));

	enableGreeting();
	OnCustomSound();
	m_cmbSound.SetCurSel(curSel);
	for (int i = 0; i < NR_CUSTOM_SOUNDS; i++)
		soundFiles[i] = contact->soundFiles[i].c_str();
	SetDlgItemText(IDC_FILE, soundFiles[curSel]);
	SetDlgItemText(IDC_GREETING, contact->greeting.c_str());

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
void 
DoubleBuffer::EraseBackground()
{
    HBRUSH  backgroundbrush = (HBRUSH)GetClassLong(m_hwnd, GCLP_HBRBACKGROUND);

    FillRect(m_buffer.m_hmemdc, &m_buffer.m_rect, backgroundbrush);
}
Пример #18
0
//---------------------------------------------------------------------------
TColCombo::TColCombo(HANDLE Par,bool Tabstop,HFONT fnt)
{
	VNumItems=0;for (int n=0;n<MAX_CC_ITEMS;n++)VItem[n]=NULL;
  VVisible=0;VLeft=0;VTop=0;VWidth=100;VHeight=200;
  VBoxGap=0;VBoxSurround=2;VBoxWidth=25;

  VParent=Par;
	for (VId=50000;VId<100000;VId++)if (GetDlgItem(VParent,VId)==NULL) break;
  Font=fnt;if (Font==NULL)Font=(HFONT)SendMessage(VParent,WM_GETFONT,0,0);

 	VHandle=CreateWindowEx(0,"COMBOBOX","",
  		CBS_DROPDOWNLIST | CBS_HASSTRINGS	| CBS_OWNERDRAWFIXED |
			WS_BORDER | (Tabstop==true ? WS_TABSTOP:0) | WS_CHILDWINDOW | WS_VSCROLL
     	,VLeft,VTop,VWidth,VHeight,
      VParent,(HANDLE) VId,(HANDLE) GetClassLong(VParent,GCL_HMODULE),0);

  if (IsWindow(VHandle)==0){VHandle=NULL;return;}

  SendMessage(VHandle,WM_SETFONT,(WPARAM)Font,0);
	HANDLE tempdc=CreateCompatibleDC(0);
  HANDLE oldfnt=SelectObject(tempdc,Font);
  SIZE sz;GetTextExtentPoint32(tempdc,"HjTTLMjpq",strlen("HjTTLMjpq"),&sz);
  SelectObject(tempdc,oldfnt);
  DeleteDC(tempdc);
  FontHeight=sz.cy;VItemHeight=FontHeight;VSelItemHeight=FontHeight+2;
	SendMessage(VHandle,CB_SETITEMHEIGHT,-1,VSelItemHeight);
	SendMessage(VHandle,CB_SETITEMHEIGHT,0,VItemHeight);
}
Пример #19
0
BOOL CSonicSkin::Attach(HWND hWnd)
{
	m_hWnd = hWnd;

	if(g_UI.Attach(hWnd, this) == FALSE)
	{
		return FALSE;
	}

	// erase NC rect
	DWORD dwStyle = GetWindowLong(hWnd, GWL_STYLE);
	DWORD dwClsStyle = GetClassLong(hWnd, GCL_STYLE);
	DWORD dwExStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
	SetClassLong(hWnd, GCL_STYLE, dwClsStyle | CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS);
	SetWindowLong(hWnd, GWL_STYLE, (dwStyle & ~WS_CAPTION & ~DS_MODALFRAME & ~DS_3DLOOK & ~DS_FIXEDSYS & ~DS_SETFONT) | WS_CLIPCHILDREN);
	SetWindowLong(hWnd, GWL_EXSTYLE, (dwExStyle & ~WS_EX_DLGMODALFRAME));
	SetWindowPos(hWnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_DRAWFRAME | SWP_NOCOPYBITS);

	// initialize
	if(m_bg.pText->IsValid() == FALSE)
	{
		TCHAR szText[256];
		GetWindowText(m_hWnd, szText, Tsizeof(szText));
		m_bg.pText->Format(_T("%s"), szText);
	}
	else
	{
		SetWindowText(m_hWnd, m_bg.pText->GetTextWithoutCtrl());
	}

	CRect rtClient;
	GetClientRect(m_hWnd, &rtClient);
	m_pPaint->Create(FALSE, rtClient.Width(), rtClient.Height(), m_hWnd);
	return TRUE;
}
Пример #20
0
int CSmcView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
    SetClassLong(GetSafeHwnd(), GCL_STYLE, GetClassLong(GetSafeHwnd(), GCL_STYLE)-CS_VREDRAW);
	return 0;
}
Пример #21
0
//读取数据
void GetExtra( HWND hWnd )
{
	long nClass = GetClassLong( hWnd, 196 );
	long nWnd = GetWindowLong( hWnd, 0 );
	char szText[256] = { 0 };
	sprintf( szText, "窗口类:%s,窗口:%d", (char*)nClass, nWnd );
	MessageBox( hWnd, szText, "Infor", MB_OK );
}
Пример #22
0
	HICON GetWindowIcon(HWND hWnd)
	{
		HICON hIcon=NULL;
		if(SendMessageTimeout(hWnd,WM_GETICON,ICON_BIG,0,SMTO_ABORTIFHUNG|SMTO_BLOCK, 1000, (DWORD_PTR *)&hIcon))
		{
			if (hIcon==NULL)
				if(!SendMessageTimeout(hWnd,WM_GETICON,ICON_SMALL,0,SMTO_ABORTIFHUNG|SMTO_BLOCK, 1000,(DWORD_PTR *)&hIcon))
					hIcon=NULL;
		}
		else
			hIcon=NULL;
		if (hIcon==NULL)
			hIcon=(HICON)(LONG_PTR)GetClassLong(hWnd,GCL_HICONSM);
		if (hIcon==NULL)
			hIcon=(HICON)(LONG_PTR)GetClassLong(hWnd,GCL_HICON);
		return hIcon;
	}
Пример #23
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdParam, int nShowCmd)
{
  g_hInst=hInstance;
 // SWELLAPP_ONLOAD or so
  
  InitCommonControls();
  Scroll_Message = RegisterWindowMessage("MSWHEEL_ROLLMSG");

  // create dialog (SWELLAPP_LOADED)
  CreateDialog(g_hInst,MAKEINTRESOURCE(IDD_DIALOG1),GetDesktopWindow(),MainDlgProc);

  for(;;)
	{	      
    MSG msg={0,};
    int vvv = GetMessage(&msg,NULL,0,0);
    if (!vvv)  break;

    if (vvv<0)
    {
      Sleep(10);
      continue;
    }
    if (!msg.hwnd)
    {
		  DispatchMessage(&msg);
      continue;
    }

    // if you want to hook any keyboard in here, the SWELL equiv is SWELLAPP_PROCESSMESSAGE


    if (g_hwnd && IsDialogMessage(g_hwnd,&msg)) continue;

    // default processing for other dialogs
    HWND hWndParent=NULL;
    HWND temphwnd = msg.hwnd;
    do
    { 
      if (GetClassLong(temphwnd, GCW_ATOM) == (INT)32770) 
      {
        hWndParent=temphwnd;
        if (!(GetWindowLong(temphwnd,GWL_STYLE)&WS_CHILD)) break; // not a child, exit 
      }
    }
    while (temphwnd = GetParent(temphwnd));
    
    if (hWndParent && IsDialogMessage(hWndParent,&msg)) continue;

		TranslateMessage(&msg);
   	DispatchMessage(&msg);

  }

  // in case g_hwnd didnt get destroyed -- this corresponds to SWELLAPP_DESTROY roughly
  if (g_hwnd) DestroyWindow(g_hwnd);

  return 0;
}
Пример #24
0
/*--------------------------------------------------------------------------
 * Function: HandleNTEvent
 *
 * Description:  This is a std. Win32 function to handle various window events
 *
 *
 *
 * Args: HWND hWnd                    // handle to window
 *       unsigned msg                 // message to process
 *       WPARAM wParam                // 32 bit msg parameter
 *       LPARAM lParam                // 32 bit msg parameter
 *
 * Return Value:
 *    int  msg.wparam                 // program done
 *
 *--------------------------------------------------------------------------*/
long
WINAPI HandleNTEvent ( HWND hWnd, unsigned msg, WPARAM wParam,
                       LPARAM lParam )

{
    PAINTSTRUCT ps;           /* used to paint the client area of a window */
    LONG addr;                /* address of our window */

    addr = GetClassLong(hWnd, 0);  /* get address */

    switch ( msg )
    {
    case WM_ACTIVATEAPP:
        hdc = GetDC(hWnd);
        /* print buffers */
        TextOut(hdc, 0 , 0, "Spaceball Ready", 15);
        TextOut(hdc, 15 , 100, "TX: 0", 5);
        TextOut(hdc, 15 , 120, "TY: 0", 5);
        TextOut(hdc, 15 , 140, "TZ: 0", 5);
        TextOut(hdc, 15 , 160, "RX: 0", 5);
        TextOut(hdc, 15 , 180, "RY: 0", 5);
        TextOut(hdc, 15 , 200, "RZ: 0", 5);

        /*release our window handle */
        ReleaseDC(hWnd,hdc);
    case WM_KEYDOWN:
    case WM_KEYUP:
        /* user hit a key to close program */
        if (wParam == VK_ESCAPE)
        {
            SendMessage ( hWndMain, WM_CLOSE, 0, 0l );
        }
        break;

    case WM_PAINT:
        /* time to paint the window */
        if (addr)
        {
            hdc = BeginPaint ( hWndMain, &ps );
            EndPaint ( hWndMain, &ps );
        }

        break;

    case WM_CLOSE:
        /* cleanup the object info created */

        break;

    case WM_DESTROY :
        PostQuitMessage (0);
        return (0);
    }
    return DefWindowProc ( hWnd, msg, wParam, lParam );

}
Пример #25
0
INT WINAPI _tWinMain(HINSTANCE hInst, HINSTANCE hPrewInst, LPTSTR lpszCmdLine, int nCmdShow){
	HWND hWnd;
	MSG Msg;
	WNDCLASSEX wcl;


	//1. Определение окна
	wcl.cbSize = sizeof(wcl);
	wcl.style = CS_HREDRAW | CS_VREDRAW;
	wcl.lpfnWndProc = WindowProc;
	wcl.cbClsExtra = 0;
	wcl.cbWndExtra = 0;
	wcl.hInstance = hInst;
	wcl.hIcon = LoadIcon(NULL, IDI_QUESTION);
	wcl.hCursor = LoadCursor(NULL, IDC_SIZEALL);
	wcl.hbrBackground = (HBRUSH)COLOR_BACKGROUND;
	//	wcl.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
	wcl.lpszMenuName = NULL;
	wcl.lpszClassName = szClassWindow;
	wcl.hIconSm = NULL;

	//2. Регистрация класса окна
	if (!RegisterClassEx(&wcl))
		return 0;

	//3. Создание окна
	hWnd = CreateWindowEx(
		0,
		szClassWindow,
		TEXT("Каркас Windows приложения"),
		WS_OVERLAPPEDWINDOW,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		NULL,
		NULL,
		hInst,
		NULL
		);

	//4. Отображение окна
	ShowWindow(hWnd, nCmdShow);
	//UpdateWindow(hWnd);

	UINT sty = GetClassLong(hWnd, GCL_STYLE);
	SetClassLong(hWnd, GCL_STYLE, sty | CS_DBLCLKS);

	//5. Запуск цикла обработки сообщений
	while (GetMessage(&Msg, NULL, 0, 0)){
		TranslateMessage(&Msg);
		DispatchMessage(&Msg);
	}
	return Msg.wParam;
}
Пример #26
0
long WINAPI HandleNTEvent ( HWND hWnd, unsigned msg, WPARAM wParam,
                           LPARAM lParam )

{

  LONG addr = GetClassLong(hWnd, 0);
  SpaceballControlStruct *scs;
  SpaceballAppDataStruct *ads;
  float *appCTM; 

  /*
   *  Make sure the SpaceballControlStruct has been initialized
   *  before we try to access it, since WindowCreate will cause this
   *  routine to get called before we set the correct address.
   */

  if (addr)
    {
    scs = (SpaceballControlStruct *)addr;
    ads = (SpaceballAppDataStruct *)(scs->appData);
    appCTM = (ads->CTM); 
    }

  switch ( msg )
    {
    case WM_KEYDOWN:
    case WM_KEYUP:
      if (wParam == VK_ESCAPE)
        SendMessage ( hWndMain, WM_CLOSE, 0, 0l );
      break;
      
    case WM_PAINT:
      if (addr)
         {
         hdc = BeginPaint ( hWndMain, &ps ); 
         Render( (float(*)[4])appCTM, ads->center);
         EndPaint ( hWndMain, &ps );
         ads->redraw = FALSE;
         }

      break;
      
    case WM_CLOSE:
      /* cleanup the object info created */
      DeleteObject ( Spw_White );
      DeleteObject ( Spw_Black  );
      break;
      
    case WM_DESTROY :
      PostQuitMessage (0);
      return (0);
    }
  return DefWindowProc ( hWnd, msg, wParam, lParam );

} /* end of HandleNTEvent */
Пример #27
0
static int DisplayRBGroup(HWND hWnd)
{
    ATOMID idWidget = KpsGetWidgetFromWindow(hWnd);
    ATOMID idValue = NULLID;
    LISTID idPossValues = NULLID;
    ATOMID idRB = NULLID;

    KpsGetOwnerSlotValues(idWidget, &idValue, &idPossValues);
    if (!idPossValues || !idValue)
    {
        KppSetSlotValue(idWidget, lpSNs->idTabStopSN,
                        lpIDs->idFalse, EXPATOM);
        KappaReturnError;
    }

    ClearParentWnd(hWnd);

    if (KppListLen(idPossValues) > 0)
    {
        LIST_LOOP loop;
        short sRBCount = 0, sW = 0, sH = 0;
        
        if (KppGetSlotValue(idWidget, lpSNs->idTabStopSN) == lpIDs->idFalse)
            KappaSetSlotInt(idWidget, lpSNs->idTabStopSN, 0);

        /* Initialize the Y-coord of (first) radio button */
        KpiInitializeCurrentYPos(hWnd, idWidget);

        /* Get the width && height of a radio button */
        GetCBWidthHeight(hWnd, &sW, &sH);

        kpc_init_loop(idPossValues, &loop);
        while (idRB = KppNextListElement(&loop)) {
            HWND hWndRB;

            KppGetAtomName(idRB, return_buffer, RET_BUFFER_LEN);
            hWndRB = CreateRB(hWnd, return_buffer, sW, sH, ++sRBCount);
            if (!hWndRB)
                KappaReturnError;

            /* Set window proc for radio button && its text */
            lpOrigCBProc = (FARPROC) GetClassLong(hWndRB, GCL_WNDPROC);
            SetWindowLong(hWndRB, GWL_WNDPROC, (long) SingleCheckBoxProc);

            /* If the radio button is the value *
             * of owner slot, then check it     */
            if (idValue == idRB)
                SendMessage(hWndRB, BM_SETCHECK, 1, 0L);
        }

        ShowAllChildCBWindows(hWnd);
    }
    
    return TRUE;
}
Пример #28
0
void initSystray(HWND hWnd, HINSTANCE hInstance) {
	NOTIFYICONDATA nidApp;
	nidApp.hWnd = hWnd;
	nidApp.uID = IDI_TRACKCOMMIT;
	nidApp.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
	nidApp.hIcon = (HICON)GetClassLong(hWnd, GCL_HICON);
	nidApp.uCallbackMessage = WM_USER_SHELLICON;
	LoadString(hInstance, IDS_APP_TITLE, nidApp.szTip, MAX_LOADSTRING);

	Shell_NotifyIcon(NIM_ADD, &nidApp);
}
Пример #29
0
void MetaTaskbar::destroyTaskSw(HWND hwnd)
{
    char className[TaskSwClassNameLen];
    taskbarControl(hwnd, TASKBAR_DEL);
    GetClassName(hwnd, className, TaskSwClassNameLen);
    HICON hOldIcon = (HICON)GetClassLong(hwnd, GCL_HICON);
    DestroyWindow(hwnd);
    UnregisterClass(className, m_pApp->m_instance);
    if (hOldIcon != NULL)
        DestroyIcon(hOldIcon);
}
Пример #30
0
BOOL CXTPMouseManager::PreTranslateMouseEvents(WPARAM wParam, POINT point)
{
	HWND hWndMouse = ::WindowFromPoint(point);
	CTrackArray& arrTracked = m_arrTracked;
	int i;

	for (i = (int)arrTracked.GetSize() - 1; i >= 0; i--)
	{
		CXTPCommandBar* pCommandBar = arrTracked[i];

		if (!pCommandBar->GetSafeHwnd())
			continue;

		int nHtCode = pCommandBar->OnMouseHitTest(point);

		if ((nHtCode != HTERROR) && ((nHtCode == HTCLIENT) || ::IsChild(pCommandBar->GetSafeHwnd(), hWndMouse) || IsRelated(pCommandBar->GetSafeHwnd(), hWndMouse)))
		{
			if (pCommandBar->m_nLockRecurse > 0 && wParam != WM_MOUSEMOVE && wParam != WM_NCMOUSEMOVE && !m_bIgnoreLButtonUp)
			{
				SendTrackLostRecurse();
				ptMouse = 0;
			}
			return FALSE;
		}
	}

	if (arrTracked.GetSize() > 0)
	{
		CTrustedArray& arrTrusted = m_arrTrusted;
		for (i = 0; i < arrTrusted.GetSize(); i++)
		{
			HWND hWnd = arrTrusted[i];
			if (IsWindow(hWnd) && IsWindowVisible(hWnd) && CXTPWindowRect(hWnd).PtInRect(point))
			{
				return FALSE;
			}
		}

	}

	if (hWndMouse && arrTracked.GetSize() > 0)
	{
		if (GetClassLong(hWndMouse, GCL_STYLE) & CS_IME)
			return FALSE;
	}

	for (i = 0; i < arrTracked.GetSize(); i++)
	{
		DeliverMessage(arrTracked.GetAt(i), wParam, point);
	}

	return FALSE;

}