|
Hello,
I've found many resources on creating and manipulating menus, but how do I simply change the default MFC MDI Main Frame menu from the default menu that VC++.net offers upon creating a new project? I'd like the replacement menu to show up when the application begins with no need for the old (VC++.net default) menu. I've tried replacing the menu resource in the resource editor, but this crashes my app.
thanks,
JennyP
|
|
|
|
|
bitpusher wrote:
I've tried replacing the menu resource in the resource editor, but this crashes my app.
That's what you need to do. You need to figure out what is wrong with your menu changes and fix it. It certainly seems very strange that even a messed up menu could crash an app. You might want to run it in the debugger and see what is happening.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Hope this an appropriate forum for this.
I'm a longtime user of C++ MFC (4.2 in VS 6.0) but new to COM (and VS2003). I'm trying to write a control using COM, so I started with the VS2003 supplied step-by-step tutorial 'dispsink'.
Using the supplied files, I was able to create and build both the client and the server. The build process (apparently) registered the control according to the log window, and I could find the entries with regedit.
However, using VS menu Tools, Active X Container, then selecting Edit:Insert New Control the name of the control does not show in the list.
I tried re-registering using File, Register... and I can see the control in that list (DispClient.DispCtl.1). But I can't get it into the Insert Control list, or into the container tool. Why can't I see it in the Insert New Control list? It seems that unless I can, it won't go into the container and I can't work with it. I'm sure I'm missing something simple - what is it?
BTW, when I tried building the tutorial by hand, step-by-step, the compiler built the client OK, but when building the server it crashed with 'serious internal error' , 'Tell Microsoft about this..." dialogs, and non-helpful diagnostics about possible wrong options ... any comments on this? (I checked my code thoroughly, but you never know for sure...)
OS is XP Pro SP2.
Any reading suggestions for getting up to speed on this topic also welcome.
caronwill
|
|
|
|
|
Than is possible to replace MFC method AfxFindResourceHandle not resorting to MFC, for example on Win32 API.
I need a method for load a resource from app and/or DLL.
Best regards,
Eugene Pustovoyt
|
|
|
|
|
Have you looked at AfxFindResourceHandle() in dllinit.cpp to see what it is doing?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Do you see this code?
AfxFindResourceHandle() method in dllinit.cpp has a few other MFC methods. What I must rewrite all this methods?
Best regards,
Eugene Pustovoyt
|
|
|
|
|
Eugene Pustovoyt wrote:
Do you see this code?
Of course. That's why I suggested the exercise. What you should have noticed, however, is that AfxFindResourceHandle() is nothing more than a fancy wrapper around FindResource() .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
From memory you just need to specify the hInstance of the EXE/DLL where the Resource lives.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Good day,
I'm having a problem with group boxes: it won't repaint controls within it in a custom / non-Doc/View MDI Window.
According to MSDN (1999: "PRB: BS_GROUPBOX-Style Child Window Background Painting Wrong"), this occurs when the parent window has the style WS_CLIPCHILDREN set. But I don't think this is the case.
In a Doc/View MDI Window, this problem doesn't occur. I compared the window style, styleex, etc. to mine, from the main window to the client, the MDI child and the formview, both are basically "same" but mine won't repaint the contents of the group box.
Ideas? Solutions (without using Doc/View MDI)?
Tnx.
|
|
|
|
|
This is just a guess, but is the group box obscuring (i.e., is it in front of or behind) the other controls?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Front. I tried the code from MSDN and handled the WM_ERASEBKGND of the group box: paint the client area with the dialog color, have the system paint the group box itself, and have the parent window redraw by trying both RedrawWindow and Invalidate. It did not work, only make the group box appear empty.
I also tried putting the group box back from the rest of the controls. The controls repainted but the group box didn't. Tried to use the same solution ending with the same result. Also modified it to enumerate the rest of the controls and have them repaint themselves (RedrawWindow & Invalidate, MSDN didn't provide a sample code how). Unfortunately, not only is it flickering but also processor intensive when fine tuning it to only redraw controls within the group box.
What I'm hoping is similar to the Doc/View Arch. where no additional code was used.
Anyway, will consider other solutions.
|
|
|
|
|
I do not know why putting the group box behind all other controls is not working for you. This method has solved problems for me in the past.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks for your time but I know now what caused this!
In order to avoid flickering (the MDI child windows are non-(user-)movable but changes size & position (including the controls in it) when the main window is resized), I overrided the WM_ERASEBKGND ON both the CMDIChildWnd and CFormView to return TRUE. Also, I handled the WM_PAINT on the CFormView to manually paint the dialog color and all the controls. It still flickered (but the group box repaints fine). I modified it and avoided the flicker, which eventually caused the group box not to repaint properly.
Problem solved!
(I have no idea why I missed it!!!)
Thanks for your time
|
|
|
|
|
Hi,
I have created a simple MFC Dialog App with a button. I have also created a Win32 Console App.
Within the dialog app, on the OnClick function of the button, I need to make a call to the Win32 Console App executable. The call can just be to start the exe and pass in some command line parameters.
Does anybody know the correct way of calling this exe and passing in command line arguments.
Cheers
Rav
|
|
|
|
|
|
ShellExecute(NULL, "file.exe", "-param1 -param2", "path", SW_SHOW);
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
You can also use CreateProcess() .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
|
This bit of code runs OK as a Win32 program:-
#include <iostream><br />
#include <fstream><br />
#include <string><br />
using namespace std;<br />
<br />
<br />
int main(int argc, char * argv[]) {<br />
string OutFile;<br />
fstream OutStream;<br />
<br />
cout << "Please enter output file name: " ;<br />
cin >> OutFile;<br />
<br />
OutStream.open(OutFile.c_str(), ios::out | ios::trunc);<br />
<br />
if(!OutStream) {<br />
cout << "Error open file " << OutFile << " for writing\n";<br />
return 1;<br />
}<br />
<br />
OutStream<<"It is easier to resist at the beginning than at the end.\n";<br />
OutStream <<" -- Leonardo da Vinci" << endl;<br />
<br />
OutStream.close();
cout << "Content written to " << OutFile <<".\n";<br />
return 0;<br />
}
But if I try the code in an MFC dialog application I get the following errors:-
c:\C_Example\DiagnosticsDlg.cpp(177): error C2039: '_open' : is not a member of 'std::basic_ofstream<_Elem,_Traits>'
with [ _Elem=char, _Traits=std::char_traits<char> ]
c:\C_Example\DiagnosticsDlg.cpp(177): error C2039: 'truc' : is not a member of 'std::basic_ios<_Elem,_Traits>' with [_Elem=char, _Traits=std::char_traits<char>]
Now if I use the statement to create/open the file
ofstream OutStream(OutFile); // Open an output stream
That seems to work, but as file not closed (as error with OutStream.close() so it is empty when viewed.
Is it a Namespace problem with the MFC classes!?!
|
|
|
|
|
We can't see any of your include statements. You need to use the Format toolbar < and > options and pre and code around your code.
It is not a good idea to use:
using namespace std;
instead only specify the namespace(s) you are actually using. eg.
using std::ofstream;
using std::ostringstream;
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Sorry, finger trouble, the includes were:-
#include <fstream>
#include <iostream> Still get error
c:\C_Example\DiagnosticsDlg.cpp(224): error C2039: '_close' : is not a member of 'std::basic_ofstream<_Elem,_Traits>'with [_Elem=char,_Traits=std::char_traits<char>]
i.e. Don't understand why problems with:-
OutStream.open(OutFile, ios::out | ios::trunc);
OutStream.close();
To get things working I need to create/open the stream as follows:-
m_cmySQLFileName.GetWindowText(strFileName);
strcpy(OutFile, strFileName);
ofstream OutStream(OutFile);
I have included the namespace suggestions,
Many thanks.
|
|
|
|
|
|
The < and > caused problems with the includes again!
#include fstream
#include iostream
|
|
|
|
|
I have been looking for a profiler/ performance analyzer app that will work ith VC++ projects similiar to the VB Watch 2 add on. I know the VB Watch 2 add on gives alot of details on where the perormance bottlenecks are down to the line of code, number of calls to functions and so on..
Does anybody know an equivalent for VC++, i have BoundsChecker, even though this is good it doesn't help with performance related issues.
Cheers!
|
|
|
|
|