|
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!
|
|
|
|
|
|
VC++ 6.0 comes with a profiler: Build->Profile...
Why not use it?
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
member "open" of "fstream" and "wfstream" has only one Ansi type
void open(const char *s, ios_base::openmode mode =
ios_base::in | ios_base::out,
long protection = 0666);
that means if i use Standard C++ Library to open a unicode named file,it will fail.
why SCL not support unicode names fstream
Stick to C++
|
|
|
|
|
My application has three dialog boxes. the first one has three buttons, Load, Modify and cancel.Load is used to display a bitmap on to the second dialog box and modify to make changes to the bitmap displayed on the second dialog. i have successfully displayed the image on the second box but cant find a way to modify the bitmap and display it on the third dialog. By modify, i mean to change the number the pixel values and the width and height of the bitmap. i tried changing the object of CBitmap to which i am loading the image and the BITMAP structure also. But it doesnt seem to change at all. Can anyone please help me out of this.
|
|
|
|