|
I am feeling like an idiot since I can't figure this out.
this->GetSafeHwnd() returns an HWND so do I cast it as CWnd?
I tried this:
CWnd* m_wwnd = (CWnd*)this->GetSafeHwnd();
CMenu* m_mMenu = m_wwnd->GetMenu();
it compiles but gives a memory fault.
Why is it so easy to get to the main window menu but not the menu attached to this child window???
Ed
|
|
|
|
|
ed9871 wrote:
I am feeling like an idiot since I can't figure this out.
I feel like this a lot when I ask questions here too, usually because my question is so basic and betrays my lack of knowledge in contrast to the professionals that hang about all day. But now that I see someone else mention it, I'm wondering, does it make any sense? Aren't we here to learn? I doubt there is such a thing as a dumb question.
- Jason
(SonorkID 100.611)
"I just recieved an email from myself but I didn't send it ?"
- Colin Davies, Sonork conference
|
|
|
|
|
Thanks Jason, it makes me feel better to know I'm not the only one who feels like this, especially after people have graciously answered my question and I still can't make it work. This seems like it should be easy, but I just can't seem to work it out.
Ed
|
|
|
|
|
ed9871 wrote:
CMenu* m_mMenu = AfxGetMainWnd()->GetMenu();
Now call GetSubMenu on the returned CMenu*
Nish
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|
|
From your document you can also access your menu through:
CDocTemplate *pTemplate = GetDocTemplate() ;
pTemplate->m_hMenuShared ;
You can get the document from the view easily.
Don;y forget to call UpdateMenuBar() etc if you change the menu.
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
Hi
anyone knows how to disable the CDROM or DVD autostart?
- Dominik
|
|
|
|
|
It's a setting under the Operating Systems / SysAdmin forum. Try there.
Jeremy L. Falcon
"You do not know the power of the dumb side."
<nobr>
Homepage : Sonork = 100.16311 Maybe my mangling might misguide malicious miscreants momentarily?
|
|
|
|
|
But i wanted to disable the autostart option programatically... i know how to disable the autostart using Windows's dialogs and the system control panel, but how to code this in C++?
|
|
|
|
|
Theres an article on MSDN about this, click
here (new window)
Dylan Kenneally
London, UK
|
|
|
|
|
Thanks!!!! That's perfect!
|
|
|
|
|
Hi there !
So this is from MSDN, so i think u should try it:
UINT g_uQueryCancelAutoPlay = 0;
BOOL DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
...
default:
if (!g_uQueryCancelAutoPlay)
{
g_uQueryCancelAutoPlay = RegisterWindowMessage(TEXT("QueryCancelAutoPlay"));
}
if (uMsg == g_uQueryCancelAutoPlay)
{
SetWindowLong(hDlg, DWL_MSGRESULT, TRUE);
return 1;
}
}
}
Hope this helps !
Olli
|
|
|
|
|
[ccode]
/*=============================================================================== Sorting a tree using CTreeCtrl::SortChildrenCB() =================================================================================*/CTreeCtrl *myTreeCtrl;static int CALLBACK MyCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort){ // lParamSort contains a pointer to the tree control.The lParam of an item is just its handle. CTreeCtrl *pmyTreeCtrl = (CTreeCtrl*) lParamSort; CString str2 = pmyTreeCtrl->GetItemText((HTREEITEM)lParam2); AfxMessageBox(str2); return 1;}//sorting treesvoid CSMPprojectDlg::SortTreeItem(){ HTREEITEM hRoot = m_TreeCtrl.GetRootItem(); HTREEITEM hNextItem = m_TreeCtrl.GetNextItem(hRoot,TVGN_NEXTVISIBLE); while( hNextItem != NULL ) { m_TreeCtrl.SetItemData(hNextItem,(DWORD)hNextItem); hNextItem = m_TreeCtrl.GetNextItem(hNextItem,TVGN_NEXTVISIBLE); } myTreeCtrl = &m_TreeCtrl; TVSORTCB tvs; tvs.hParent = m_TreeCtrl.GetRootItem(); tvs.lpfnCompare = MyCompareProc; tvs.lParam = (LPARAM)myTreeCtrl; m_TreeCtrl.SortChildrenCB(&tvs); MessageBox("hello");}void CSMPprojectDlg::SortingAtree(){ SortTreeItem();}
//but the messagebox in callback function print empty string... it is suppose to be print whatever i had set ( in my case file information, which are .type_size_date (.txt_231_5/3/02) )to
tv_instruct tree;tree.item.lParam = type_size_date;
[/ccode]
when inserting to tree.
i want to sort by date,by type, and by size like window explore
anyone have the same experience??
|
|
|
|
|
How are you setting items' data with SetItemData ? I suspect here lies the problem.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
this is how i set item data..
HTREEITEM hRoot = m_TreeCtrl.GetRootItem();
HTREEITEM hNextItem = m_TreeCtrl.GetNextItem(hRoot,1);
while( hNextItem != NULL )
{
m_TreeCtrl.SetItemData(hNextItem,(DWORD)hNextItem);
hNextItem = m_TreeCtrl.GetNextItem(hNextItem,1);
}
|
|
|
|
|
hi
how can i read all the data from a Com port without knowing before hand how many Bytes are to be read?
i am using the function:
ReadFile(hCommPort,Buffer,sizeof(Buffer),&nBytesRead);
i only get 4096 Bytes into the buffer but the file i am reading can be 4 times more than that!how can i get it all?would appreciate if anyone can help in any way.
|
|
|
|
|
I never did anything with the COM port functions but normally you call data-retrieving functions several times to retrieve the data in small pieces...
I had a look in the MSDN and the first line in the description of the ReadFile function is:
The ReadFile function reads data from a file, starting at the position indicated by the file pointer.
I didn't test it but i think you can read small pieces until the function reports an EOF.
|
|
|
|
|
The third argument to readfile is how many bytes yopu're trying to read. You're trying to read sizeof(Buffer) bytes. Now, I'm guessing that you've allocated buffer as:
BYTE buffer[4096];
change it and you're sorted.
Signature space for rent. Apply Within.
|
|
|
|
|
Read from the serial port a byte at a time until you get no bytes returned. Don;t forget to configure the COM port to retrun immediately after a read otherwise it will wait for the data and block your thread.
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
Hi there,
I wrote a simple game by windows GDI functions in MFC dialog based exe project.
But my program has great problem !
It is about flickering images on dialog !
I must show some images on the dialog after getting keys from user !
For drawing pictures on the dialog i must use CDC in OnPaint() ...
So, how could i show my pictures without flickering ?
Plz help me !
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
|
Hi Dominik,
Thanks for reply,
But his example was in SDI template ...
How can i use his idea in dialog based program ?
Plz help me
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Sorry for my silly question: What is automation for?
Thanks
|
|
|
|
|
In a nutshell, it's a special interface for a COM object. To be automatable, the object should support the IDispatch interface. You can then automate (call functions, etc.) that object with another program, or a VB script, or what have you.
You can write these interefaces in a speical langauge (IDL I think it's called), and create a type library so that other programs can link to the COM object easier.
Just a fancy addition on top of COM.
No generalization is 100% true.
Not even this one.
|
|
|
|
|
i have a static library built with VC6. internally, it uses STL.
when i try to link that into a VS.Net project (an MFC project, not C# or anything), i get a set of linker errors relating to std::logic_error, std::length_error and std::out_of_range - all unresolved externals.
did MS make changes to these classes ? does this mean any static lib built with VC6 will not work in VC7, if it uses STL ? WTF ?
-c
There ain't no second chance
Against the thing with the forty eyes
|
|
|
|
|
Sure they did a lot of changes to the internals of STL containers as well as some of the interfaces (like the inclusion of standard-compliant allocators.) So one could expect this kind of problems.
That said, maybe the particular problems you have are minor and could be solved without having to recompile the lib. Could you post them in length? (if you please )
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|