|
sorry, i should've done this before!!!
Thanks for the advise
|
|
|
|
|
I checked all the doc/view classses but didnt find a handler for the pre-existing VC ID_FILE_OPEN menu item. Which class handles the COMMAND for this ID? If it were the view class, and I wanted to remotely trigger this menu, could I say:
AFxGetMAinWnd()->SendMessage(WM_COMMAND, ID_FILE_OPEN)?
Does it matter who is handling this command? CAn this work even if any class were to be handling it?
Thanks,
ns
|
|
|
|
|
CWinApp does, or your CWinApp derived class does.
You should find these entries in your CWinApp derived class's message map
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
Thank you. So why do we send a message to the AfxGetMainWnd() object rather than AfxGetApp()? THe former works. Havent tried the latter.
One odd thing I found is that if my menu item is handled locally by the class thats sending the message, I dont have to Afx -> sendmessage it, just a direct sendmessage (since its to this->). So looks like the message has to be sent to the class that handles the command. In retrospect thats obvious....
So why AfxGetMainWnd (which returns the mainframe right? )and not AfxGetApp who is handling the ID?
Thanks,
ns
|
|
|
|
|
I got the error:
C:\swanke\A20\WzdView.cpp(124) : error C2039: 'SendMessageA' : is not a member of 'CWinApp'
So I suppose we have no choice but to send it to MAinWnd......I wonder why we cant send messages to the app???
|
|
|
|
|
The CWinApp object itself is not a window and cannot "receive the message" itself. What happens I think is that the CMAinFrame command router pass's it through a message map belonging to the app/mainframe/doc/view (these may not be in the right order here) in order looking for the first one that handles the call.
So AfxGetMainWnd()->SendMessage() will get to the app object due to the internal MFC routing mechanism.
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
MAny thanks. I need to read more about the message passing mechanism. SO I'm gathering that AfxGetMAinWnd is giving us back an object even hif=gher than the app object (which I thought was the highest) . The name makes it sound like its going to give back a CMAINFRAME * object, which I thought was aminframe object. Anywaqys sorry if this sounds confused...I'll do some reading. APpreciate your help!
ns
|
|
|
|
|
Both CWnd s and CWinApp s are CCmdTarget s and are therefore capable of providing handlers for commands. Note that true window messages (WM_mumble ) can only be sent/posted to CWnds . The command routing mechanism of the doc/view architecture works like this:
- The
CView object gets first dibs at handling the message.
- If it doesn't handle it, the enclosing frame window gets a chance.
- If it doesn't handle it, the
CDocument attached to the view gets a chance.
- If it doesn't handle it, the
CWinApp object gets the message. Many standard commands are "automagically" handled because CWinApp provides handlers for them. Examples are File|Open,Save, Exit, Help, etc.
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Actually, the order is like this:
1. The active view gets the first shot at processing the message
2. Then the document associated with the view gets it's chance
3. The document template is next.
4. The mainframe get's its chance now.
5. Finally, the application object gets it's chance.
6. If noone handled this message it goes to ::DefWndProc( );
This applies to WM_COMMAND and WM_NOTIFY messages.
|
|
|
|
|
Ooops - you're right! Thanks!
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hello,
I need to implement database access in my application. MS SQL server will be used. What are your reccomanadtions about technology to use: ODBC, OLEDB, ADO?? What something else MS Platform provide?
I thinked about ADO, but frankly I preffer to avoid the COM stuff in my app.
But, I think OLEDB is also a COM thing, is it true?
And if I shall use ODBC, I should need a long development time?
Please send me your advice.
Thanks,
MN
|
|
|
|
|
Ok Don,
Since your looking for answers. Can you handle the truth?
I finally decided to go with ADO for a recent project. I'm pretty new to database stuff in C++ and wanted to go with one of the technologies that should be around for at least another month or two. Our company already had an out of date ODBC library that I hated and DAO is simply going the way of the birds. One big reason for going with ADO was Carlos Antollini's fine ADO libraries or articles on this site. It is a great starting place and the class structures work well with my application. ADO just seemed like the right strategy for my work. Take a look at Carlo's articles and see if it is right for your project.
|
|
|
|
|
Robert Vista wrote:
Take a look at Carlo's articles and see if it is right for your project.
Thanks Robert, I forgoten to mention that large amount of free tutorials
could also be a factor in decision.
Robert Vista wrote:
out of date ODBC library
what do you mean? I thinked at backward compatibility, and so on, I think
ODBC will be supported long time from now by Windows, and will evolve also...
And another thing: which of the layer support transactions better??
Thanks.
|
|
|
|
|
I have a simple yes or no question: is the Calendar Control broken(hence all the wrapper controls)
And what I mean by that is that you cannot control the fact that it changes months when the grayed out numbers are clicked
More importantly when you select multiple days that painting is horrible.
Is there any 'know' bugs?
|
|
|
|
|
My application (Win32, no MFC) has the following window structure:
dlgA (main window, CreateDialog)
dlgB (data area, CreateDialog, owned by dlgA)
wndC (input window, CreateWindow, owned by dlgB)
wndD (another input window, CreateWindow, owned by wndC)
Now here's what happens:
I close wndD and the focus switches back to wndC (as expected)
I close wndC and the focus switches to the desktop (unexpected)
If I give wndD the WS_CHILD style dlgB gets the focus after closing wndC, but I want it to have the WS_POPUP style instead, because it is a popup generated by wndC should be drawn outside of its client area (as it can be considerably larger than wndC).
If I close wndC without ever opening wndD (which is created only when I click a certain button in wndC), it also works correctly.
Any idea what this can be? It's driving me crazy.
|
|
|
|
|
Hello,
I looked for sample code on the web and msdn to see how to use this to make buttons show up dynamically. I'm not sure how to use this function. CAn someone give me a sample of how to use this?
I tried:
void CMainFrame::OnAddbutton()
{
TBBUTTON tbButton[2];
tbButton[1].fsStyle = TBSTYLE_BUTTON;
m_wndToolBar.GetToolBarCtrl().AddButtons(2,tbButton);
}
but I'm sure I'm missing something.
Thanks you,
ns
|
|
|
|
|
Try this:
CToolBarCtrl* pBar = &(m_wndToolBar.GetToolBarCtrl());
tbbuttonStruct.iBitmap = pBar->AddBitmap(1, pBitmapNew);
/* pBitmapNew is a pointer on a dynamically allocated CBitmap,
containing the button image, it should be freed at the end of the program */
tbbuttonStruct.idCommand = ID_MY_COMMAND;
/* user define */
tbbuttonStruct.dwData = 0 /*Image Index*/;
tbbuttonStruct.fsState = TBSTATE_ENABLED;
pBar->AddButtons(1, &tbbuttonStruct);
HTH,
K.
We do not inherit the Earth from our ancestors. We borrow it from our children.
Antoine de Saint Exupéry (1900-1944)
|
|
|
|
|
I want to display the thumbnails of images in some folder, using VC++. I tried using the IExtractImage interface, provided by the shell (supposedly!)
I get a compile-time error about the interface not being found. I use Windows2000, so I believe it's not a problem with the shell version. I could not find IExtractImage in shlobj.h.
Is there any way for getting the thumbnails?
Thanks.
Logic is a systematic method of coming to the wrong conclusion with
confidence.
|
|
|
|
|
Please click and go the following link for your reference. Good luck!
http://netez.com/2xExplorer/shellFAQ/bas_infos.html
Golden Lee
|
|
|
|
|
It's this site which I have been referring to. I tried out the sample code given therein, and am getting the compile-time error about IExtractImage interface.
http://netez.com/2xExplorer/shellFAQ/bas_infos.html
-Karthika
Logic is a systematic method of coming to the wrong conclusion with
confidence.
|
|
|
|
|
If I remember well, you should install first the Core SDK to use IExtractImage interface.
HTH,
K.
We do not inherit the Earth from our ancestors. We borrow it from our children.
Antoine de Saint Exupéry (1900-1944)
|
|
|
|
|
For adding a propertypage in a propertysheet in use the fonction AddPage.
But I need to specify the index where the page will be added.
I cannot use RemovePage to remove all page and add all pages after that.
Is possible or not?
|
|
|
|
|
Hi,
i have a app running a listview (in icon view only) and I desperately need to make the texts under the icons blue, underlined and clickable (single-click)... any Ideas? I tried SetBkColor to affect the text's background, not worked, I tried setting a new brush for the dc, also no good. OWNERDRAW style would be probably useless as MSDN says it is supported in report view only. ANY hints?? Thanks
|
|
|
|
|
You would probably have to recode the way ListCtrl items are drawn, through a derived class, to have exactly what you want. For a list view, have a look to the NM_CUSTOMDRAW notification. You may find some articles on his site about it.
HTH,
K.
We do not inherit the Earth from our ancestors. We borrow it from our children.
Antoine de Saint Exupéry (1900-1944)
|
|
|
|
|
Okay, so now I know how to change the drawing.... I don't presume there are chances it is possible to use the text as some kind of anchor, but... is it? I need it to react to a single click (not double) on the text (simply to make the application to handle a click to the icon itself (in icon view mode) handlin a click commonly and to handle the click on the text using some ie. pre-set function... thanks. (my only cue is the HOTTRACK capatibility, but that seems to be too "spread" so that a lot of bug would be involved (handling the mouse separately and checking for the hottrack and keydown and calculating where the item was clicked (btw. that may be important: I always know the size of the item... i can rely on that) thanks
|
|
|
|