|
-
August 14th, 1999, 11:55 AM
#1
window to foreground
1. how to put window box to foreground? (there is no taskbar button).
2. I want to put wbox to foreground any time when parked mouse cursor on icon in systray.
-
August 14th, 1999, 02:51 PM
#2
Re: window to foreground
Use SetForegroundWindow(hwnd);
(hwnd is the handle of the window you're moving to the foreground)
-
August 15th, 1999, 02:15 AM
#3
Re: window to foreground
error C2660: 'SetForegroundWindow' : function does not take 1 parameters
-
August 15th, 1999, 02:25 AM
#4
Re: window to foreground
Well if you're using mfc instead of win32, you call the function as
cwndclasspointer->SetForeGroundWindow();
or if you're using mfc and have a hwnd handle instead of a class pointer call it as
::SetForeGroundWindow(hwnd);
-
August 15th, 1999, 04:40 AM
#5
Re: window to foreground
Tried, but without success.
OK, I'm going (still) working on it but, what I want: when clicked with LeftButton on icon (which is in Systray), I want to bring me window box up/top. (For case if something hide it/lay of it, well, you know...).
-
August 15th, 1999, 04:41 AM
#6
Re: window to foreground
Oh, yes, I'm using MFC (dialog box).
-
August 15th, 1999, 05:16 AM
#7
Re: window to foreground
I found two interesting fuctions:
One is window position, which is a little bit complicated, and the second, more interesting is
BringWindowToTop ().
But, something strange... header bar (this blue bar on top of the window) are still "grayed" - like some "activate" missing. I test this when the window is foreground.
If it is in background - well, it stays there 
-
August 15th, 1999, 07:18 AM
#8
Re: window to foreground
so, u have popped up a dialog when clicking on the systray icon on the systemtray. For this u whd. have captured the message which u whd. have specified in ur NOTIFYICONDATA structure...
While popping the dialog ur code will be like this
CSomeDialog dlg;
dlg.DoModal();
Okay
in the Initdialog of the CSomeDialog u include this line of code
SetForegroundWindow();
At later time when u click leftmousebutton on the icon and u want ur dialog popped already to be in the foreground, u should make the instance of the dialog as a member to the class in which u r capturing the leftmouseclick of icon and use that membervariable and call SetForegroundWindow()
This will solve ur problem...
Thanks lot,
Srini.
-
August 15th, 1999, 10:41 AM
#9
Re: window to foreground
Wow-ouch...unfortunately I don't use NOTIFYICONDATA.
And now, you asked, for Gratious Sake, then what this man use 
Well, the first, my intention is, of coarse only to put icon at SysTray. Then I'm searching, searching, and what find - only some pseudo examples. The "Beginner" category means nothing, as I saw. One, example, is near to be The Example, but this one made window box transparent and doesn't work quite well.
So, thanks to God, I exidently press ActiveX - and U know what - can U imagine, find TrayIconPrj.TrayIcon. (VC++ v5.0) - and when I choose that - icon apears in SysTray. This "project" also has mouse buttons - one click, doubleclicks, left, right, middle...So, only what I need was to made Menu and link, properties, what to do when the Exit is choosen (and I put there IDOK). Great! Stuffs works like baby.
But then, wait a minute, what will happend when my prgy be covered by another one (and U know, I turnoff toolbar button), how to bring this mine window up? So, the best way, seems to me is to make leftclick on the icon, which will pull window to front, top.
So, because my logical mechanisam is totally contra of (whole) Microsoft and this is because I want to know what I'm doing, it's however clear to me that I'm going to become patient, depender, too. Bla, bla, bla...
So, what I have now:
Only one class (I really don't know what is it, subprogram, what?) named ocdDlg[.cpp] and of coarse start prg "ocd.cpp".
And in ocdDlg.cpp there are key stuffs about what we are talking:
======================================================================================
// this one works correct
void COcdDlg::OnRightButtonClickTrayicon1()
{
CMenu m_Menu;
CPoint point;
GetCursorPos(&point);
m_Menu.LoadMenu( IDR_MENU1 );
CMenu* pPopup = m_Menu.GetSubMenu( 0 );
pPopup->TrackPopupMenu( TPM_RIGHTBUTTON, point.x, point.y, this );
}
void COcdDlg::OnLeftButtonClickTrayicon1()
{
// and these are blind bullets.
// CWnd* pTopParent = GetTopLevelParent();
// SetForegroundWindow((HWND) hwnd);
// SetFocus();
// BringWindowToTop ();
CWnd* pParent=GetTopLevelParent();
SetForegroundWindow();
// BOOL SetWindowPos(hwnd,HWND_TOP,/*wndTop*/0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
// SetWindowPos(wndTop,0,0,0,0, SWP_NOSIZE);
// AfxMessageBox("pizda");
}
========================================================================================
What is interesting, when I put SetForegroundWindow(); and click on icon, (and my window is TOP to see it - this "blue ribbon" (header tray, where the name of window is, blinks severel times, (4 times, I think) between blue and gray, and parked to gray - no active.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|