|
|
no.. no.. you misunderstood me. I create a new menu bar using MFC. not my own drawing.. just regular menu bar.. I want to attachment it to my MainFrame but don't know how.
for example..
when you choose Single Document while you were creating application or building a new project, the menu bar get created too. The menu bar contains
File Edit View Help you can add more menu item to there.
I have created a new menu bar by Insert Menu then I type in only
File in side File only have New and Exit I don't want anything else like original menu bar File which consists, New, open, save,close,save as, exit...
I only want to know how to attach the menu bar to my application??
Thanks
|
|
|
|
|
In the .cpp of your application Class, add the following lines (in BOLD) for attaching an user defined menu...eg shows system menu getting replaced by IDR_MY_MENU1
(Like you I am also learning..hence if this fails please do not hold me responsible ). If there is any other better that you come across let me know
CSingleDocTemplate* pDocTemplate;<br />
pDocTemplate = new CSingleDocTemplate(<br />
IDR_MAINFRAME,<br />
RUNTIME_CLASS(CMyDoc),<br />
RUNTIME_CLASS(CMainFrame),
RUNTIME_CLASS(CMyView));<br />
AddDocTemplate(pDocTemplate);<br />
CCommandLineInfo cmdInfo;<br />
ParseCommandLine(cmdInfo);<br />
if (!ProcessShellCommand(cmdInfo))<br />
return FALSE;<br />
<br />
CMenu* pMenu = m_pMainWnd->GetMenu();<br />
if (pMenu)<br />
pMenu->DestroyMenu();<br />
<br />
pMenu = new CMenu();<br />
pMenu->LoadMenu(IDR_MY_MENU1);<br />
m_pMainWnd->SetMenu(pMenu);<br />
((CMainFrame*)m_pMainWnd)->m_hMenuDefault = pMenu->GetSafeHmenu();<br />
m_pMainWnd->ShowWindow(SW_SHOW);<br />
m_pMainWnd->UpdateWindow();<br />
<br />
return TRUE;<br />
-Mahesh Shimpi
Ideas multiply by sharing!!
|
|
|
|
|
Thank you very much for your help... That's what I wanted..
Thank you.
|
|
|
|
|
Hey Everybody,
I am using CListCtrl in my application with check boxes.
By default windows provides various selection mechanism like
1. 'click' on an item, OR
2. multiple files by pressing 'ctrl' key and clicking on various items OR
3. using 'shift' and page down/up or end/home to select all item etc..
However mere selection does not check the checkboxes of the selected items. I want to implement functionality whereby as soon as a selection is made the check boxes gets checked.
1. What notification message should I trap?
2. Can somebody just give a pseudo code OR various steps in doing so?
Using "OnClick" I can trap a single item selection and I can set its check state. Problem is when I do a select using Shift + End/Home OR Shift + PageUp/Down. At this point I am not sure what message should be trapped to check the selection of the item and mark it checked.
I tried something to do like this with the notify mesg
BOOL CMyListView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
LPNMLVODSTATECHANGE pNMListView = (LPNMLVODSTATECHANGE) lParam;
NMHDR pNMHDR = (NMHDR)pNMListView->hdr;
if (pNMListView->uOldState == 0 && pNMListView->uNewState == 0)
{
*pResult = 0;
return FALSE; // Do nothing and return
}
//ELSE
//Here I think I should have got items with selected state set so
//that I can call SetCheck on the item and programmitically to
//check the checkbox for those items.
//Please advise..
}
Thanks in Advance
-Mahesh Shimpi
Ideas multiply by sharing!!
|
|
|
|
|
Is there a notification that I can get when my dialog is resized? Thanks.
|
|
|
|
|
WM_SIZE, there are some MFC classes here
|
|
|
|
|
Hi,
In the visual c++ envirment i opened a peoject, but i need to change its name, Is there a way to change the name of the workpsace?
thanks
|
|
|
|
|
I think the only way is to create a new project and Add To Project all the files that were in the first one. I could be wrong though....
|
|
|
|
|
|
I am trying to implement a CStatic control that has horizontally centered text with word break, and centered vertically as well. This control will be displaying multiple lines (as word break implies).
I tried getting the text extent by the following:
if (m_bCenterVert){<br />
CSize sz = pDCMem->GetTextExtent(strText);<br />
TEXTMETRIC tm;<br />
::ZeroMemory(&tm,sizeof(tm));<br />
pDCMem->GetTextMetrics(&tm);<br />
if (sz.cy <= tm.tmHeight){<br />
int y = rc.CenterPoint().y;<br />
y -= (tm.tmHeight / 2);<br />
rc.OffsetRect(0,y - rc.top);<br />
}<br />
}<br />
pDCMem->DrawText(strText,rc,dwFlags);
I think what is happening is the GetTextExtnent() is not showing the extent after the word breaking is done? It always adjusts to the center of the control, and the bottom line gets clipped.
Is there a better way?
Thanks.
(P.S.) How the heck do I indent my source code properly in one of these messages?
|
|
|
|
|
Hello there,
I'm using WinXP and i installed Farsi language as Non-
Unicode on it.
I wanted to write a MFC program by VC++ .NET
VC++ .NET supports Farsi language, too.
I changed my dialog language to Farsi.
The problem is when i put a static box in dialog and when
i want to write a farsi string in the static box caption,
VC++ change my string to ?????? (question mark characters)
What's wrong ?
Regards,
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hi Hadi:
Have you find the solution?I have the same problem with my XP and VC.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
Hello dear Mazdak,
Unfortunatly, No
But I installed WinXP as usual in the company, then i installed VS .NET
It works fine on that !
I can't really understand what's wrong
I asked this question in Microsoft Newsgroup too.
They got confused too
If i found the answer i'll tell ya
With Best Regards,
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Whilst testing some code from the framework I have been working on in various Win32 platforms I came across a rather odd bug.
Lets say we have the following:
HBITMAP hbmpOrig = getImageListHBMP()
where hbmpOrig represents the HBITMAP to a properly created bitmap image in memory
Now I want to make a copy of the handle, and according to MSDN there is a nice function called CopyImage that does just this.
So I do the following:
HBITMAP hbmpCopy = (HBITMAP)CopyImage( hbmpOrig, IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG );
Now according to the MSDN that I have at home (which is the Oct 98 MSDN that comes with VC6):
<quote>
CopyImage
<snip>
...
fuFlags
<snip>
LR_COPYRETURNORG Creates an exact copy of the image, ignoring the cxDesired and cyDesired parameters.
This is why I used the LR_COPYRETURNORG - to make a copy of the image.
The behavior on Win2000 (all sp versions), WinXP, Win98 (and presumably on 95 and ME as well) is to create a new HBITMAP value - just like the docs say.
However on Win NT4 it returns a the original value!! So this is a problem that was in the framework. One of the guys helping out on the project posted this problem to a newsgroup (or list, or whatever) on MSDN and this is what a Microsoft eng replied as :
>
> I don't think I understand - the docs for LR_COPYRETURNORG state
> that you will get back the original if it meets the criteria. Since
> you're asking for 0 width and height, the only way the original
> wouldn't satisfy your request is if it's a different bit depth.
>
> The difference in behavior is either a bug in NT4, or due to the
> color depth in which you're running on the various machines. Either
> way, you could very easily create your own CopyImage() which creates
> a new bitmap and uses BitBlt() to copy the image from source to target.
Sure enough I checked on the latest MSDN docs for this and they read:
<quote>
CopyImage
<snip>
...
fuFlags
<snip>
LR_COPYRETURNORG
Returns the original hImage if it satisfies the criteria for the copy—that is, correct dimensions and color depth—in which case the LR_COPYDELETEORG flag is ignored. If this flag is not specified, a new object is always created.
WTF ! This is the behaviour on WinNT4 but NO OTHER system performs like this!!! Which is correct ? Do we just use 0 ?
So I am curious - has anyone else ran into this before ? Is there a workable solution or do we just end up writing our own version of CopyImage? This is just so incredibly annoying. Actually it is a lot more than that but I am going to refrain from a stream of expletives...sigh.
Thanks in advance !
¡El diablo está en mis pantalones! ¡Mire, mire!
|
|
|
|
|
I'd say write your own. I know that TransparentBlt also has trouble, quite a few people have ended up using my version and it's solved their problems with it. It seems Microsoft are not infallible
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Hi,
I create a Dialog box with some controls.
I would like to use my Dialog box for another application in VC++.
How can I do for import this dialog with all controls ?
Best Regards
youssef
|
|
|
|
|
Do you mean import? One solution is to import the dialog box class in the new project. Export the dialog box template and import it in the new project.
If you meant controlling the dialog box in another program, then you should consider other solutions including file-mapping, namepipe, Winsock, and COM.
Kuphryn
|
|
|
|
|
When I go to the dialog box that I want to export, the context menu can't display Export but only import.
youssef
|
|
|
|
|
i have an MDI application with 2 views .
Initially in the App class I do the following :
CMultiDocTemplate* pDocTemplate;<br />
pDocTemplate = new CMultiDocTemplate(<br />
IDR_MDI2TYPE,<br />
RUNTIME_CLASS(CMDI2Doc),<br />
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CPersonalityGenerator1View));<br />
AddDocTemplate(pDocTemplate);<br />
<br />
<br />
secondTemplate = new CMultiDocTemplate(<br />
IDR_MDI2TYPE,<br />
RUNTIME_CLASS(CMDI2Doc),<br />
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(View1));
// I DO NOT ADD THIS SECOND TEMPLATE
On a New document I do the following :
if (!CDocument::OnNewDocument())<br />
return FALSE;<br />
<br />
CMDI2App *myApp=(CMDI2App *)AfxGetApp();<br />
CMainFrame *mnd= (CMainFrame *)(myApp->m_pMainWnd);<br />
CFrameWnd *allotedFrameWnd;<br />
allotedFrameWnd=myApp->secondTemplate->CreateNewFrame(this,0);<br />
myApp->secondTemplate->InitialUpdateFrame(allotedFrameWnd,this, TRUE);<br />
allotedFrameWnd->SetActiveWindow();<br />
allotedFrameWnd->ShowWindow(SW_HIDE);
I am suppressing this second View by hiding it AND i display the first view . This is what i want initially !
Now I need to activate this view on an On Button Event from the Toolbar
In the active View i am trying to do something as :
<br />
void CFirstView::OnSwitchView()<br />
{<br />
<br />
POSITION pos = this->GetDocument()->GetFirstViewPosition();<br />
<br />
CView *v2 = this->GetDocument()->GetNextView(pos);<br />
<br />
v2->GetActiveWindow();<br />
<br />
v2->GetParentFrame()->ShowWindow(SW_SHOW);<br />
}
I find that the views are not getting switched . I observe no change . Please help
|
|
|
|
|
I'm looking for an explanation of how to detect an idle period within an application and close dialogs and log off the application if the idle period is exceeded.
I have information on how to detect the application idle time by using Paul D.'s IdleUI DLL from Feb. 2000 MSJ, but I'm curious how to find a modal dialog that is currently displayed and close it. Will I have to send a user windows message to the dialog and write a message loop for the dialog to get it?
Any one of a number of modal dialogs in the app can be displayed when the idle time is exceeded and I can't seem to figure out how to notify these dialogs that they should close. Also, will I even get system hook notifications in the main app if a modal dialog is currently displayed?
Thanks...
|
|
|
|
|
Do you have control of the dialog boxes? Call its destroy function, DestroyWindow(), or post a WM_DESTROY message.
Kuphryn
|
|
|
|
|
I have an Application in Vc++ . From this application I want to invoke another Application .
Imagine invoking Notepad to view a file .
How do I do this ?
|
|
|
|
|
_spawn, CreateProcess, WinExec and ShellExecute are all popular methods.
-c
A conclusion is simply the place where someone got tired of thinking.
|
|
|
|
|
For a command line:
Use system if you want the command line interpreter to handle it.
Use ShellExecute/ShellExecuteEx if you want the Windows shell to handle it.
Use CreateProcess if you want Windows to handle it.
|
|
|
|