|
Check for WM_SYSCOMMAND and then SC_CLOSE .
When you click on those buttons on the title bar a WM_SYSCOMMAND is generated. Now what kind of event happened is determined by the wParam parameter. Check the wParam parameter to find out if X (SC_CLOSE ) was clicked.
Here is a sample done with WindowProc...
LRESULT CVolMacDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if( message == WM_SYSCOMMAND && wParam == SC_CLOSE )
{
if( MessageBox(_T( "Are you sure you want to quit?" ), _T( "Prompt?" ), MB_YESNO ) == IDNO)
return 0;
}
return CDialog::WindowProc(message, wParam, lParam);
} Well this is done with a dialog, it will work with views too but it will require some additional housekeeping too. Hope this helps.
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
Hi ,
Check this out :-
(In Pretranslate Message)
if ( pMsg->message == WM_NCLBUTTONDOWN) // non client LButton Down
{
if ( pMsg->wParam == HTCLOSE) // the close button is going to be pressed
{
}
}
Regards,
FarPointer
|
|
|
|
|
I have a dialog box with the Title Bar setting set to False. This means that the Minimize Bar setting is False as well. This is why I can't minimize the application when I click on the icon task bar, but I would like this to happen.Any suggestions?
Thank you!
|
|
|
|
|
Junyor wrote: This is why I can't minimize the application when I click on the icon task bar, but I would like this to happen.Any suggestions?
You can send a WM_SYSCOMMAND message with wParam parameter set to SC_MINIMIZE .
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
i hope this code might be helpful to u.
bool bClientWinState = false;//define and declare this variable in OninitDialog(); of your application. handle the OnNotifyIcon event like this:
LRESULT CMyApplication::OnNotifyIcon(WPARAM wParam, LPARAM lParam)
{
UINT uID;
UINT uMouseMsg;
uID = (UINT) wParam;
uMouseMsg = (UINT) lParam;
if ((uMouseMsg == WM_LBUTTONDOWN) || (uMouseMsg == WM_LBUTTONDBLCLK))
{
if(bClientWinState)
{
AfxGetApp()->m_pMainWnd->ShowWindow(SW_RESTORE);
AfxGetApp()->m_pMainWnd->SetForegroundWindow();
bClientWinState = false;
}
else
{
AfxGetApp()->m_pMainWnd->ShowWindow(SW_MINIMIZE);
this->ShowWindow(SW_HIDE);
bClientWinState = true;
}
}
]
jiteen tilekar
Siemens Info. systems Ltd., Pune
|
|
|
|
|
good idea, just what's the message number of clicking the icon in the taskbar instead of system tray area. I think we need to respond
the message to minimize our application.
Nothing impossible, Nothing sure
|
|
|
|
|
I answer to your question in previous message
whitesky
|
|
|
|
|
As you know, we can lock taskbar manually, But I would like to lock taskbar by my own program. I try to do it by the following code:
DWORD style = GetWindowLong(hShellTrayWnd,GWL_STYLE);
style &= ~WS_SIZEBOX;
SetWindowLong(hShellTrayWnd, GWL_STYLE, style);
Unfortunately, it didn't work as I expected. Does anyone know how to do it?
Your help would be greatly appreciated.
Nothing impossible, Nothing sure
|
|
|
|
|
I did do it sometime back but don't have the message number with me now.
Maybe I can give it you tomorrow.
This requires you to send a message to the taskbar asking it to lock itself. I did have the number but don't have it now.
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
Hi Tomas,
Your help would be greatly appreciated, in fact I send WM+USER+336 to taskbar, but it didn't work, which make me feel that it can't be done by sending a message.
And then I try another way below:
CToolBar* trayWnd = (CToolBar*)FromHandle(hShellTrayWnd);
DWORD barStyle = trayWnd->GetBarStyle();
barStyle |= CBRS_SIZE_FIXED;
trayWnd->SetBarStyle(barStyle);
It also didn't work, I was really frustrated, the style of taskbar vary every time even though I remove "trayWnd->SetBarStyle(barStyle)".
For example, sometimes barStyle is 380, but sometimes it is 376, and other times, it is another value. it is very strange for me.
Nothing impossible, Nothing sure
|
|
|
|
|
NianHawk wrote: Hi Tomas,
Your help would be greatly appreciated, in fact I send WM+USER+336 to taskbar, but it didn't work, which make me feel that it can't be done by sending a message.
Thanks.
This works on both Windows XP, 2000...
#define <code>WM_USERDEF_LOCKTASKBAR </code>424
static HWND hShellWnd = ::FindWindow(_T("Shell_TrayWnd"), NULL);
if(hShellWnd != NULL)
::PostMessage(hShellWnd, WM_COMMAND, MAKELONG(<code>WM_USERDEF_LOCKTASKBAR</code>, 0), NULL);
else
hShellWnd = ::FindWindow(_T("Shell_TrayWnd"), NULL); This will work!
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
It did work well, thank a lot. I have another question if you wouldn't feel disturbed, Actually I use spy to monitor taskbar, if my program send such WM_COMMAND msg to taskbar, spy can capture it.
But if I do it manually by using winxp functionality, spy didn't show this msg, that is why I always can't get this msg. Could you be so kind to teach me something about it?
Nothing impossible, Nothing sure
|
|
|
|
|
NianHawk wrote: It did work well, thank a lot.
You are Welcome
NianHawk wrote: I have another question if you wouldn't feel disturbed,
Not at all.
NianHawk wrote: Actually I use spy to monitor taskbar, if my program send such WM_COMMAND msg to taskbar, spy can capture it.
But if I do it manually by using winxp functionality,
Which functionality!
NianHawk wrote: Could you be so kind to teach me something about it?
Can you give me your email. I can send you a sample application, which demonstrates some useful messages related to the TaskBar.
BTW here is a list if you are interested...
305,
401,
402,
403,
404,
405,
407,
408,
413,
415,
416,
419,
420,
421,
424,
503,
505,
506,
510,
41093,
41094
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
Thanks for your help.
I mis-thought there had not benn reply yet because I didn't receive the response mail as usual, maybe last time I missed to check "Notify me by e-mail if someone answers this message".
My email is : NianHawk@invalid.hotmail.com (please discard "invalid").
Which functionality!
===> I just lock the taskbar by taskbar menu.
Best regards.
Nothing impossible, Nothing sure
|
|
|
|
|
NianHawk wrote: Thanks for your help.
I mis-thought there had not benn reply yet because I didn't receive the response mail as usual, maybe last time I missed to check "Notify me by e-mail if someone answers this message".
My email is : NianHawk@invalid.hotmail.com (please discard "invalid").
Heh don't worry. I wrote an article on this subject. You can get the sample application from here[^]. Hope you will like it.
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
Thanks a lot
Nothing impossible, Nothing sure
|
|
|
|
|
If I wish to draw a window, or an image onto the desktop, do I use obtain a HWND from GetDesktopWindow() and get a DC from there? I wish to draw onto the desktop , so that my image appears as though it were part of the wallpaper, e.g. all other windows sit on top of it.
Is there another HWND I should be looking for?
|
|
|
|
|
Aneurysm00 wrote: If I wish to draw a window, or an image onto the desktop, do I use obtain a HWND from GetDesktopWindow() and get a DC from there? I wish to draw onto the desktop , so that my image appears as though it were part of the wallpaper, e.g. all other windows sit on top of it.
Create DC by using this method
CDC myDC(NULL);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi ,
Do you really have to draw on the desktop ,wont overriding the
CWnd::OnEraseBkgnd of your window work .that will give the same effect as drawing on the Desktop. Please check .
Regards,
FarPointer
|
|
|
|
|
Hi,
I have an application in which I display records in a grid. I populate the grid using a recordset that contains the results of a query of the database.
The problem is that if I have a large database (about 80,000 records and above..) then it takes a few minutes to load the grid with all of the records.
I need to make this faster... Any ideas?
|
|
|
|
|
|
Yeah - what I thought to do is show the first 400 records (for example), while searching for the other records.
I thought to load the data page by page, and display 400 records in each page.
So, it would work this way: display 400 records, then display another 400 (800 total), then another 400 (1200 total) and so on until I reach 78000 records.
But how can I do this with the recordset object?
Do I have to fill the recordset first with 400 records, then with 800 records, then with 1200 records, and eventually with 78000?
|
|
|
|
|
SWDevil wrote: So, it would work this way: display 400 records, then display another 400 (800 total), then another 400 (1200 total) and so on until I reach 78000 records.
only load the ones you need to display. if they scroll, load enough new data to complete the grid, and discard the rest.
ideally, if your grid control allows, you can put it in charge of loading the data for the rows it has to display when it needs them. don't make it load data it doesn't need - just let it ask for rows X through Y when it needs to display them, and don't worry about any other rows.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
ok - I understand your idea, but I don't understand how to actually implement it...
First of all - how can I know if I can put my grid control in charge of loading the data it needs?
Second - Let's say my grid control can't be put in charge of loading the correct data, how do I implement your idea?
Do I have to perform a new query each time?
For example: "SELECT * FROM TABLE1 WHERE field BETWEEN x and y" and then display the recordset that contains the result set?
Also - won't this solution take a lot of time also? isn't the solution of loading page by page better?
|
|
|
|
|
SWDevil wrote: how can I know if I can put my grid control in charge of loading the data it needs?
i don't know what you're using for your grid, but some of the standard Windows controls allow this. for example, the CListCtrl can act as a "Virtual list control", which means it will send you a message when it needs data for an item. the MSDN has info on this.
SWDevil wrote: Do I have to perform a new query each time?
ideally, you would cache some data.
SWDevil wrote: Also - won't this solution take a lot of time also? isn't the solution of loading page by page better?
you're only ever loading, at most, the number of lines you can display at once, so the control will load faster and won't be required to maintain a large amount of memory to hold all the items.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|