|
Relying on byte alignment is dangerous and makes for hard to maintain code.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
|
Every time I try to start a debug session the entire .Net visual studio application locks up and I have to restart it. Even if I create a new MFC application and add nothing to it, the app hangs.
I can run it without debugging just fine, but when I try to "start", no way.
Any thoughts?
"Thank you, thank you very much" Elvis.
|
|
|
|
|
I'm trying to create a view class derived from CListView. It is created as the main view object of an MDI application, by the appwizard on project creation.
OnInitialUpdate() is where you place the code that initializes a view. My problem is that I can't seem to get the CListView to show the column headers. Can anyone see what I'm doing wrong? (Here's my OnInitialUpdate
void CMailBoxProtoView::OnInitialUpdate()
{
CListView::OnInitialUpdate();
int x;
// Get a reference to the list view's control
CListCtrl& listCtrl = this->GetListCtrl();
// Add the columns
listCtrl.InsertColumn(0, _T("From"), LVCFMT_LEFT);
listCtrl.InsertColumn(1, _T("Received"), LVCFMT_LEFT);
listCtrl.InsertColumn(2, _T("Subject"), LVCFMT_LEFT);
listCtrl.InsertColumn(3, _T("Size"), LVCFMT_LEFT);
// Set the column sizes
for(x = 0; x < 4; x++)
listCtrl.SetColumnWidth(x, LVSCW_AUTOSIZE_USEHEADER);
// Set the style of the list control
listCtrl.SetExtendedStyle(LVS_REPORT);
// This displays fine, but where's the headings?!
listCtrl.InsertItem(0, "Item0");
}
Many thanx,
funbag!
skydiving....if at first you don't succeed, you're fecked!
|
|
|
|
|
I test your code and it's ok,problem is not here.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
that's really strange! I can't seem to get it going at all. You think maybe there might be a message I'm not mapping or something???
skydiving....if at first you don't succeed, you're fecked!
|
|
|
|
|
overriden OnCreate of your view class and change it to this:
int CYourView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
lpCreateStruct->style |= LVS_REPORT;
if (CListView::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Thank you thank you thank you thank you thank you
(and I didn't use copy and paste there either!)
It works great! Thank you!
skydiving....if at first you don't succeed, you're fecked!
|
|
|
|
|
In MFC Doc/View SDI or MDI application, every command message sent by menu items or buttons in a toolbar can be routed to CMainFram::OnCmdMsg(..) function. Howevey, if I want to menually send a command message using:
<br />
SendMessage(AfxGetMainWnd(), WM_COMMAND, ID_MYCOMMAND, 0);<br />
or using
<br />
PostMessage(AfxGetMainWnd(), WM_COMMAND, ID_MYCOMMAND, 0);<br />
this message doesn't get routed to CMainFram::OnCmdMsg(..). Why? In other words, how can I simulate the menu command message using SendMessage or PostMessage?
|
|
|
|
|
You're sending/posting the message correctly. However, you need a handler of the form:
ON_COMMAND(ID_MYCOMMAND, OnMyCommand) /ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Thanks. I did have the command handler. The message sent by SendMessage or PostMessage did get routed to CMainFrame::OnCommand(...) function not CMainFrame::OnCmdMsg(...). But the message sent by a menu item gets routed to CMainFrame::OnCmdMsg(...). What I am wondering is that the difference between those two mechanism.
|
|
|
|
|
Hmmm, that's odd. The command handler for IDC_MYCOMMAND should get called for the menu item IDC_MYCOMMAND. Perhaps the notification isn't being passed down the chain.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
The command handler gets called actually for either mechanism but it seems so via different road. Menu command thru OnCmdMessage, and mannually sent command thru OnCommand.
The reason I ask this question is that the command handler may be located in a View or Doc class, not necessary in CMainFrame class, if the menually sent command message is routed to CMainFrame::OnCmdMsg function, then I had the chance to forward the message to other classes capable of handling message.
|
|
|
|
|
as far as I can see all WM_COMMAND messages gets routed to the receiving windows' OnCommand handler, which in turn calls OnCmdMsg (provided some prerequisites are present).
Call stack:
CCmdTarget::OnCmdMsg
CWinApp::OnCmdMsg
CWnd::OnCmdMsg
CView::OnCmdMsg
CFrameWnd::OnCmdMsg
CWnd::OnCommand
CFrameWnd::OnCommand
CWnd::OnWndMsg
CWnd::WindowProc
AfxCallWndProc
AfxWndProc
So your SendMessage and your menu selection should all be routed through OnCommand first and then to OnCmdMsg. You could put a breakpoint in OnCmdMsg and check on the call stack that OnCmdMsg is called from OnCommand in both instances.
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Steen Krogsgaard wrote:
So your SendMessage and your menu selection should all be routed through OnCommand first and then to OnCmdMsg. You could put a breakpoint in OnCmdMsg and check on the call stack that OnCmdMsg is called from OnCommand in both instances.
I did exactly what you described above but I did not see the command got routed to OnCmdMsg. However, it did get routed to OnCommand function. Odd, huh.
Is there any difference between menu sent message and message sent by SentMessage or PostMessage?
|
|
|
|
|
I made a little test program with three menu items: The Option, Post It and Send It. The Option just displays a message box. Post It and Send It posts or sends a WM_COMMAND with IDC_THE_OPTION as wParam to the AfxGetMainWnd() window. I have overriden the view OnCmdMsg and the framewnd OnCmdMsg (it's a SDI app) and put traces in if IDC_THE_OPTION (or any of the other two menu items) passes through.
I get what I'd expect: Everything goes through first CFrameWnd::OnCmdMsg and the CView::OnCmdMsg. So there must be something else "wrong" with your app.
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
I appreciated your helped me on this question. I used an MDI app and overriden the CMainFrame's OnCommand. To test if the command message is routed to this function I used an IF statement to see the command ID.
I am wondering if you could make a test MDI program on this point, zipped it and sent it to me via email to convince me?
Thank you so much!
|
|
|
|
|
I tried to mail the MDI program to you but your mailer won't allow a 5 meg zip attach.
Anyway, the result is that invoking the command through a menu selection or through SendMessage/PostMessage yield identical call patterns. CMainFrame::OnCommand is called, followed by CChildFrame::OnCommand, which calls CChildFrame::OnCmdMsg and CView::OnCmdMsg. CMainFrame::OnCmdMsg is not called because CChildFrame::OnCmdMsg handles the command (returns TRUE) and thereby shortcuts CMainFrame::OnCommand.
One thing that may confuse you is that ON_COMMAND_UI handling is routed through some of the same pathway, namely CMainFrame::OnCmdMsg, CChildFrame::OnCmdMsg and finally CView::OnCmdMsg. Here only the menu selection invocation will cause this chain to be called, as SendMessage/PostMessage does not relate to the UI and hence does not provoke UI updating. So if you just checked whether CMainFrame::OnCmdMsg was called at all you'd see a difference between menu selection and Send-/PostMessage, but that's not for the WM_COMMAND message, thats for MFC's private UI update mechanisms (illustrated by the fact that OnCommand is not called in response to UI updates).
This is the best I can do. If you are absolutely sure that WM_COMMAND send by a menu and send by Send-/PostMessage leads to different call stacks I suggest you write a minimum program to reproduce the problem and send it to me or to this forum (oops! I just recommended posting code, sorry!!!)
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
I am very convinced by your explanation here. Thank you so much!
Have a nice weekend.
|
|
|
|
|
Does VC7 offer support for WinXP-64/Itanium targets?
Thanks,
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
|
Hi,
I want to pass metafile to my ATl control ( from an MFC client), is there any easy way to do that, something pretty cool would be like:
MyAtlCtrlInstace->PassMetafile(hMyMetafile) ( VT_METAFILE)
But it seems that I have to use IOleDataObject ( but I don´t want drag and drop and that stuff just directly call it from the client!!!!), is there any easy way to do that ?, if not... which method should I override from IOleDataObjectImpl ?
Thanks in avance, Bye !
Braulio
|
|
|
|
|
Sorry to disappoint you that I don't know the answer but I can help you in another way,because it seems you are really in trouble;) (2 or 3 message about this problem in disccution board)
Anyway,Have you read Dr.Grimes books about ATL programming?(wrox publisher)There are two version ,one for Begginers and another one is for prof. I have the begginer version but there is nothing useful about this subject in it,maybe if you find prof. one it can help you.
I also have Dr.Grimes email address,one time he helped me to solve my problem in ATL ,if you want I can send it for you,I think he helps you
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Hi,
Anyway thanks for your help ( yes I feel like a dummy sorry , just posting posting..., aaaah !).
Sometimes to do something wiht ATL looks like weird or complicated but.... well... just give a metafile !!! oh my god !... I think I´m going bananas
If you can give me the address of Dr. Grimes I will send one e-mail, but I don´t know if he will answer me...
Thanks anyway, Bye !
Braulio
|
|
|
|
|
atl.dev@grimes.demon.co.uk
If you ask how should I write my project,he won't answer.Ask your question as you ask them here,"SHORT" and "COMPLETE",he answers the questions that thier answers are one or two line,just like this question
Good luck
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|