|
It sounds like you are needing a system-wide hook. See if SetWindowsHookEx() works.
|
|
|
|
|
Forgive me if I am using the wrong terminology.
By system tool bar I mean the bar that defaults to the top of each application. The bar that host the minimize, maximize and close buttons.
Two questions.
(1) what is this area of the screen correctly called? Is it the frame?
(2) Can you point me towards an article that would show me how to add a button to this bar?
thanks
|
|
|
|
|
McGahanFL wrote:
Can you point me towards an article that would show me how to add a button to this bar?
There actually is one here on CodeProject about that!
I don't remember where because it was like hell to find it when I was searching for it!
Happy searching! (if not somebody post the link)
Rickard Andersson8
Here is my card, contact me later!
UIN: 50302279
E-Mail: nikado@pc.nu
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
Hi,
I have a DlgApp that launch other applications. When the user click on a button, a popup menu is created with some data that I have collected in my database. The user then need to select an item into the menu. The selected info is used as parameters to launch the other app.
This is my click button handler:
void CmyDlg::OnBnClickedBtnDbmanager()
{
CMenu myMenu;
CRect rect;
m_wndDBBtn.GetWindowRect(&rect);
monMenu.CreatePopupMenu();
monMenu.AppendMenu(MF_STRING, 0, "Name1");
monMenu.AppendMenu(MF_STRING, 0, "Name2");
monMenu.AppendMenu(MF_STRING, 0, "Name3");
monMenu.AppendMenu(MF_STRING, 0, "Name4");
myMenu.TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON, rect.left+20, rect.top+20, AfxGetMainWnd());
}
I would like to know how I can get the index of the menu. For example, if I select name4 into the menu, I would like something to tell me that the fourth item is selected... After that, I can use GetMenuString() to retrieve my data and launch my other App.
As you can see, unstead of ID as second parameter into AppendMenu() I have 0. The reason of this is that I dont know how many info I will have to put into my menu, so i can't provide ID for each of them.
Any Ideas?
Everything's beautiful if you look at it long enough...
|
|
|
|
|
a) Specify the index as second parameter in AppendMenu
b) use TrackPopupmenuEx, and specify TPM_RETURNCMD in the flags.
The return value will contain the value passed as second parameter to AppendMenu
c) NEVER EVER use an User Interface String (such as the one displayed in the menu) directly for further processing. Don't do that. Never. it is not done.
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
MemLeak wrote:
I would like to know how I can get the index of the menu.
Assign the menu items unique IDs starting with 1 and incrementing. Add the TPM_RETURNCMD flag to TrackPopupMenu() and it will return the ID of the item the user selected, or 0 if he cancelled the menu.
--Mike--
Latest blog entry: *drool* (Alyson) [May 10]
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
Anyone know of a problem with the old fprintf function? I have been using it for years now and all of a sudden during some testing it has started to crash inside the call.
|
|
|
|
|
iltallman wrote:
I have been using it for years now and all of a sudden during some testing it has started to crash inside the call.
Could you be trying to reference a memory location that no longer exists?
-Nick Parker
|
|
|
|
|
No. I looked in the debugger at all the data and attributes - it all looked good with appropriate NULL ending strings
|
|
|
|
|
well -- fprintf works fine for me when I don't do something boneheaded.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Santa Cruz Networks / VidiTel / Reality Fusion (pick a name -- may change at any moment)
|
|
|
|
|
I had a case once, where I did something like this.
<br />
char *str = GetSomeInputString();<br />
fprintf( F, str );<br />
worked pretty well, but would crash once in awhile when someone put a %s.
changed it to:
fprintf( F, "%s", str );
all is well.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Santa Cruz Networks / VidiTel / Reality Fusion (pick a name -- may change at any moment)
|
|
|
|
|
fprintf has always worked well for me. Except when I did something boneheaded like you point out.
Sometimes I have done things like
int i = 8675309;<br />
char *str = GetSomeString()<br />
fprintf(F, "%s", i, str);
|
|
|
|
|
Robert Little wrote:
int i = 8675309;
Reminds me of a song!!
|
|
|
|
|
I've done that too.
None of us are exempted from bonehead mistakes..... I've certainly had my share, and unfortunately they seem to be the most difficult to track down...
It's my guess that the writer of this question made some boneheaded mistake....
Have fun!
P.S. I don't really consider fprintf to be old....
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Santa Cruz Networks / VidiTel / Reality Fusion (pick a name -- may change at any moment)
|
|
|
|
|
A common problem with formatting is that the parameters don't match the formatting string, and VC++ doesn't do a check to see if they match.
Elaine
The tigress is here
|
|
|
|
|
I've been trying to use the MSComm serial communications control with a Doc/View architecture but can't seem to find a way to access the OnComm windows message directly in the View class... Can it only be accessed from a dialog class? (I though adding an object of the control in the View header file (CMSComm m_comm;) would allow me to "see" the OnComm windows handler in Class Wizard.
Using the MSComm control in a dialog box is fairly easy... you bring in the control and double click on it in the dialog box to add the OnComm message handler to your dialog box class. What if you don't want the dialog box sitting on your view...I'd like to respond to serial port data and draw lines on the View.
|
|
|
|
|
Hi,
When I use window, if I right click on the desktop, there is a menu that display refresh,copy, paste etc..
I would like to be able to do something similar to that. In a DlgApp, if I click on a button, I would like to see a menu appear from witch I can choose data. What kind of control do I have to use?
Any ideas on how to achieve that?
thanks
Everything's beautiful if you look at it long enough...
|
|
|
|
|
see TrackPopupMenu in the documentation
|
|
|
|
|
|
I have been working on an application that displays data in various labels and textfields.
How can I size the application to the correct dimensions video card settings (display settings)?
thanks,
sj
|
|
|
|
|
Call GetSystemMetrics with the following:
SM_CXSCREEN,
SM_CYSCREEN
|
|
|
|
|
I am writing an application that upon the user pressing a funciton key the applicaiton is dispalyed. Even if the user is using another program and this key is pressed.
I have tried using the following functions but if I have notepad(or other app) maximized and press the button my appication does not come to top.
ShowWindow
BringWindowToTop
SetWindowPos
I have confirmed the hot key is being recognized by poping up a dialog box when it is pressed. I have confirmed the correct handle by using SetWindowPos to move the window. Is there another approach/function I should be using
Thank you,
SAK
|
|
|
|
|
One solution is ShowWindow().
ShowWindow(SW_RESTORE);
Kuphryn
|
|
|
|
|
I've made a horizontal scrollbar control using CreateWindowEx, and on the WM_HSCROLL event in the parent window I do this:
if (flag == SB_LEFT)<br />
{<br />
curPos -= 1;<br />
}<br />
<br />
else if (flag == SB_RIGHT)<br />
{<br />
curPos += 1;<br />
}<br />
<br />
else if (flag == SB_LINELEFT || flag == SB_PAGELEFT)<br />
{<br />
curPos -= 1;<br />
}<br />
<br />
else if (flag == SB_LINERIGHT || flag == SB_PAGERIGHT)<br />
{<br />
curPos += 1;<br />
}<br />
<br />
else if (flag == SB_THUMBTRACK || flag == SB_THUMBPOSITION)<br />
{<br />
curPos = position;<br />
}
Then using SetScrollPos(hWndScroll, SB_CTL, curPos, TRUE) I try to let the scrollbar be updated, but it doesn't seem to work. any ideas?
LPCTSTR Dutch = TEXT("Double Dutch ");
|
|
|
|
|
Hi.
I have a faulty app that I should restart whenever it crashes.
I can easily see when it's dead, since it creates a named mutex that disappear with the app.
My problem is that if the app crashes and shows a MessageBox
as this example:
The instruction at "0x004015b0" referenced memory at "0x00000000". The memory could not be "written".
Click on OK to terminate the program
Click on CANCEL to debug the program
Is there any way to avoid this? I can't modify the darned app's source code.
thanks in advance,
bye
M.
|
|
|
|