|
Hi Martin,
You must be using TrackPopupMenu for invoking pop up menu, isn't it ?
Now, I'll tell you ,steps I followed to got it working.
1. Create a menu in resource editor with pop-up style.
2. Use CMenu::LoadMenu to load that menu.
3. Use SetMenuInfo as described in your original post.
4. Use TrackPopupMenu , set its parent as main frame window.
5. Override DefWndProc of CMainFrame (or you can use PreTranslateMessage ).
6. I can see WM_MENUCOMMAND sent when clicked this menu.
May this give you some idea.
|
|
|
|
|
Ok - got it working - a bit different than you told me to, and with a lot of consequences.
The current state:
1. we have a MFC application
2. our MFC application has a resource based menu, with one ON_COMMAND handler per menu item
3. I wrote a tcl API to access the MFC application menu, which allows to create new sub menus and menu items.
4. before I insert a popup menu, I switch the MFC application menu MENUINFO to MNS_NOTIFYBYPOS , so that WM_MENUCOMMAND messages are used, instead of WM_COMMAND messages
5. after inserting a popup menu, I switch the new sub menu to use WM_MENUCOMMAND messages
6. I registered a ON_MESSAGE handler for WM_MENUCOMMAND messages
The consequences:
1. None of the resource based menu items, with ON_COMMAND handlers, will work anymore, because there are no WM_COMMAND messages anymore
2. every selected menu item causes the wanted WM_MENUCOMMAND message
3. every menu in the "path" of (sub)menus seem to have this MENUINFO style flag MNS_NOTIFYBYPOS , so that this model is really working.
If I don't switch all containing menus of a sub menus to send WM_MENUCOMMAND messages, than the whole model won't work.
The suggestion above to use TrackPopupMenu must work, if the popup menu is used all alone, but if it is used inside a "path" of cascaded menus, than this would be more problematic.
4. the whole menu system of ON_COMMAND handlers must be rewritten, or I must find a way to get rid of the dummy or template menu item and create resources on the fly, but ... I don't know how!
A change of question:
How do I create on-the-fly resources or menu items with new, non-existing IDs?
If I'd know, how to create on-the-fly resources, than I could stay with the normal WM_COMMAND system.
Thanks to you Prasad!
Best regards, and a happy weekend!
Martin Lemburg
|
|
|
|
|
Dear All
I have following problem:
In a multi threaded application I want to debug my program.
But when I set break point one one thread, I find that all the threads are suspended. (In visual C++ 6 environment)
Is there any way to block the thread that we want to see its bahavior , without blocking other threads.
Regards
Mahdi
|
|
|
|
|
I don't have an answer to your question but I really don't see why you want to do that ? Is there any particular reason to do that ?
|
|
|
|
|
One of my threads works with hardware, and an small time of disconnection will resutl in intefrace error with hardware.
Because of it.
|
|
|
|
|
|
Hi all,
I have the following problem. I using a while loop, and if the user hits any key I prompt the user whether he/she wants to exit (Thats working ... awaiting previous thread). The problem comes in when the users selects No, when every loop cycle it asks the same question over and over again. How can I clear the buffer of the key board hit funtion ??
while(1)
{
if(kbhit())
{
UINT msg_rc;
msg_rc = MessageBox(NULL,"Are you sure you want to close the TCP/IP Server","Confirmation",MB_YESNOCANCEL);
if (msg_rc == IDYES)
{
exit(1);
break;
}
}
....
Many thanx
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
else
{
printf( "\nKey struck was '%c'\n", _getch() );
}
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
I overlooked , that you got answer, reading printf statement in this post. And posted my reply.
Any way, use _getch() , at the start in if statement instead of else . So that it will be executed irrespective of condition.
|
|
|
|
|
Use _getch .
while(1)
{
if(kbhit())
{
_getch();
UINT msg_rc;
msg_rc = MessageBox(NULL,"Are you sure you want to close the TCP/IP Server","Confirmation",MB_YESNOCANCEL);
if (msg_rc == IDYES)
{
exit(1);
break;
}
}
-- modified at 4:18 Friday 16th February, 2007
Didn't noticed that you already got your answer, I ignore your second post, seeing its printf statement.
|
|
|
|
|
Just out of curiosity, why are you using kbhit() and getch() with a GUI application? Those functions had their place with console applications, but with Windows, much more elegant solutions exist.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi all,
I have the following piece of code that displays a messagebox, it's working and everything, but how can I display an icon in the message box. I am well aware of the MB_ICONEXCLAMATION, MB_ICONWARNING ... ext, but I want to use a yes - no button with a question mark icon:
msg_rc = MessageBox(NULL,"Are you sure you want to close the TCP/IP Server","Confirmation",MB_YESNOCANCEL);
Many thanx
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
msg_rc = MessageBox(NULL,
"Are you sure you want to close the TCP/IP Server",
"Confirmation",
MB_YESNOCANCEL <code>| MB_ICONQUESTION</code>);
|
|
|
|
|
Thank you very much toxcct ...
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
When using the EDITTEXT control, if I try to use the SHIFT+ENTER (hard line break as defined in MS Word), the resulting text produces a carriage return.
When I look at the string once I have edited and saved the text, the SHIFT+ENTER results in ascii 0x0D (ascii decimal value 13). However, I was expecting it to be ascii 0x0B (ascii decimal value 11).
How could I differentiate an ENTER and a SHIFT+ENTER in a simple text edit control? Or is this not possible in a simple edit text control?
|
|
|
|
|
deivakumar wrote: However, I was expecting it to be ascii 0x0B (ascii decimal value 11).
I'm just curious, why did you expect 0B? That's a Vertical Tab (VT).
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Newlines are represented by the sequence \r\n (0D 0A hex) in Windows.
|
|
|
|
|
Hello,
First, I'm pretty sure someone already asked this question, but I couldn't find the right keywords (I did try for about 60 minutes and read pretty much other interesting stuff though), so I hope I'm not annoying anyone.
Anyway, I'm having a multi-document application that each view shows different camera in a 3D scene. I have the code to draw the frame for each view, but of course I need a continuous update. I tried 3 methods and each had its drawbacks so I'd really appriciate any suggestions.
Here are the methods:
1. (The trivial one) - at the end of the code of the OnDraw I'm invalidating the entire view. (this method even that it worked in some other applications I wrote, failed and the application entered deadlock).
2. When view is initialized, I create a thread that paints the view continuously. (deadlock).
3. The thread sends continuously WM_PAINT messages. (works for one view but when I have more than one view the application again enters deadlock)
4. The thread loop send WM_PAINT and then Sleep(1) (works. Sleep(0) enters deadlock.)
5. One thread that sends all the views WM_PAINT (deadlock even with the Sleep).
so now I'm using method 4. The problem in both 3 and 4 is that the framerate drops down. and in 4 it becomes really slow (1/3 of the potential that 3D apps actually can get on the same computer).
does anyone have any idea why does those deadlock happens?
some more information that might be required is that the draw function is implemented in an engine that takes the handle of the window to draw to and it handles itself all the context switching.
maybe I will have to dig in in that engine and see if the problem lies there, but first I wanted to give a shot for the windowing system.
thanks a lot,
Guy.
p.s.
I also appologize for my english.
|
|
|
|
|
Doesn't CDocument::UpdateAllViews fits for your sccenario.
BishGada wrote: does anyone have any idea why does those deadlock happens?
I can tell about 1'st deadlock. You are using Invalidate in OnDraw which will cause endless reccursion.
|
|
|
|
|
Hi
I am trying to create a Windows Service using the function 'CreateService'.
LocalSystem Account service gets created quite easily..
But, when I try to create service with Network Service Account
with 'NT AUTHORITY\NetworkService' or 'NT AUTHORITY\LocalService'
the function fails
Looks I am using the wrong combination of the last 2 params
'lpServiceStartName' and 'lpPassword'...
I am providing...".\user" in 'lpServiceStartName' and pwd in 'lpPassword'
Please guide what are the correct values that have to be passed here...
Thnx
...A Programmer may or may not be the master of the programming language grammar...
|
|
|
|
|
AbbyIndian wrote: Looks I am using the wrong combination of the last 2 params
'lpServiceStartName' and 'lpPassword'...
I am providing...".\user" in 'lpServiceStartName' and pwd in 'lpPassword'
NT AUTHORITY\NetworkService is a special built-in user account.
I believe the lpServiceStartName param sould be be "NT AUTHORITY\NetworkService"
and the lpPassword param should be "" (an empty string). Check the docs!
Mark
Great job, team. Head back to base for debriefing and cocktails.
|
|
|
|
|
Hi Mark
Yeah..the docs say that and I have used that combination...but its not working.
The function returns Error Code 87..which is 'ERROR_INVALID_PARAMETER'
H E L P !!!
...A Programmer may or may not be the master of the programming language grammar...
|
|
|
|
|
Can you post the code for the entire CreateService() call?
Mark
Great job, team. Head back to base for debriefing and cocktails.
|
|
|
|
|
Hi..
Here's the relevant code
SC_HANDLE hSCM = ::OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
SC_HANDLE hService = ::CreateService(
hSCM, m_szServiceName, m_szServiceName,
SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS|SERVICE_INTERACTIVE_PROCESS,
SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL,
szFilePath, NULL, NULL, _T("RCQSS\0"), _T("NT AUTHORITY\NetworkService"), NULL);
..The problem is in the last 2 params only...coz if I make the last 2 params NULL,NULL...the
service gets created and entries are made in the registry with Objectname=LocalService
And I want the ObjectName to be 'NT AUTHORITY\NetworkService'
Another possibility: Maybe, some others params don't just create the perfect combination
when the service name is NetworkService..and hence they also need to be changed when the second last param is 'NT AUTHORITY\NetworkService'...
Thnx
...A Programmer may or may not be the master of the programming language grammar...
|
|
|
|
|
Is _T("RCQSS\0") a valid group name? If so, what if you try _T("+RCQSS\0")?
The last two params can affect others. Just for fun, try removing the SERVICE_INTERACTIVE_PROCESS
flag and see if it works.
Also, an empty string (_T("")) should be passed as the last parameter instead of NULL, although
that's most likely unrelated to the problem.
I'm also not sure if you can use SERVICE_ALL_ACCESS access rights under the system network
account.
Great job, team. Head back to base for debriefing and cocktails.
|
|
|
|
|