|
I'm not sure if I understand. I have the following code:
CStatic m_text;
m_text.SetWindowText(_T("hello there"));
I get a "Debug Assertion Failed" error and the program dies.
Did I do something wrong?
Thanks,
Pat
|
|
|
|
|
PatP07 wrote: CStatic m_text;
That's not enough, that just creates an instance of the MFC class. To create the underlying Win32 window, you need to call Create on it.
|
|
|
|
|
Here's an example copied from MSDN.
CStatic myStatic;
myStatic.Create(_T("my static"), WS_CHILD|WS_VISIBLE|SS_CENTER,
CRect(10,10,150,50), pParentWnd);
myStatic should not be a short lived local variable, so it may be a good idea to make it a member of the container class.
|
|
|
|
|
Ok, got it to work...thanks a lot!
P.
|
|
|
|
|
In addition to Nishant's answer:
The C++ objects are just simple wrappers around the Windows API. When you do "raw" windows programming, you deal with window handles. You've probably seen them in code - HWND is their C/C++ type. When you program without MFC or any other toolkit, you either use the builtin functions such as SetWindowText() , or manipulate the windows by sending different messages to them.
What MFC does for the common control windows, such as labels (CStatic ), is that it wraps the window handle, and provides C++ methods for manipulating the windows. The methods then call the corresponding Windows API function or sends the appropriate message with parameters.
What this wrapping business means is that you actually have two objects to maintain in your code! In the case of m_text , there's the actual C++ object, and the actual window. These two object's lifetimes are not synchronized. When the m_text object's constructor has executed, the window object is not yet created. It is created in a successful call to Create() . When DestroyWindow() is called later on, the window object is destroyed, but the C++ object remains. Whenever the window object is not alive, most methods on any CWnd derived class are not available.
--
Pictures[^] from my Japan trip.
|
|
|
|
|
Hi
I want to know how i can extract an exe into memory and then execute it directly from memory. Any idea or ref . Pl. help me.
thanks
|
|
|
|
|
|
He wrote: into memory
he wants to do it "on the fly" not wanting to land on disk !!
"But your mind is very complex, very tricky. It makes simple things complicated. -- that's its work. And for centuries it has been trained for only one thing: to make things so complicated that your life becomes impossible."- Osho
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1"> --[V]--
|
|
|
|
|
VivekuniQ wrote: he wants to do it "on the fly" not wanting to land on disk !!
there no way AFAIK... but maybe he can write a temporary exe on the disk, ShellExecute() it, and when it exits, delete the file...?!
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
|
|
|
|
|
I want to execute exe directly from memory. I am writing a binder that will bind my project files and execute them to the memoty.I am doing this to make single exe out of several. Any idea or ref.
|
|
|
|
|
is it ok for you, instead of creating an exe "in memory" an launch it as is, to create threads and processes instead ?
as i am understanding your last comment, you're trying to make several independant units that are running separatedly (but maybe synchronized). this way, threads may be what you're looking for...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
|
|
|
|
|
Well that sounds great.
should i load exe that is at the end of main exe file and create a process with the address of second exe.
well i have joined (appended) 2 exe files. now i want to load 2nd exe (which is at end of 1st exe) to the memory.
|
|
|
|
|
You can embed binary files as "binary" resources inside your exe, easy as embeding an icon.
Then you can save the binary contents as a "temporary" .exe, and execute it.
I hope it helps
Guimasun
GuimaSun
www.nexsun.com.br
NEXSUN TechZone
|
|
|
|
|
Hi
Thanks a lot for help.
I think there is no way to execute exe file from memory.
So i am going to use ShellExecute().
well if i find out any way i'll ley you know.
thanks
|
|
|
|
|
I've a Project with many sub-projects attached to it, in that there are many MDI classes with several Dialogs. I need to change the property(appearance,font,color) of text in those dialogs, making it look equally applied throughout.
I dont think so, i can manually code every dialog to appear same, so i'm looking to write a class that would change the appearance of the text throughout the projects(all dialogs). I'm wondering how to go about this, any one could give me an idea in detail plssss.
Mohan
|
|
|
|
|
I'm using ini file for translation purpose, and to translate dialog I have a call DlgTranslate(this) from OnInitDialog in every dialog. This function traverses all dialog controls, changing text accordingly.
This was long preface The key is that recently I need to adjust font of static controls, and doing this in DlgTranslate was a good choice (while not very structured). You can do similar thing in your case too.
Igor Green
http://www.grigsoft.com/ - files and folders comparison tools
|
|
|
|
|
hi all,
i am working on parser..
i want to write Context free grammar in c++ using templates
can one tell me is it possible if so how and provifde some links
thanks
geeta
Gets
|
|
|
|
|
Spirit[^] is an object oriented recursive descent parser framework implemented using template meta-programming techniques. Expression templates allow us to approximate the syntax of Extended Backus Normal Form (EBNF) completely in C++. Parser objects are composed through operator overloading and the result is a backtracking, top down parser that is capable of parsing rather ambiguous grammars.
The Spirit framework enables a target grammar to be written exclusively in C++. Inline EBNF grammar specifications can mix freely with other C++ code and, thanks to the generative power of C++ templates, are immediately executable.
Spirit is part of Boost[^] Libraries, a peer-reviewed, open collaborative development effort.
|
|
|
|
|
How to Change of Background Color of dialog box,with options?
Manmohan
|
|
|
|
|
Handle the WM_ERASEBKGND message for the dialog.
OnEraseBkgnd(CDC* pDC)<br />
{<br />
CRect rect;<br />
GetClientRect(&rect);<br />
pDC->FillSolidRect(&rect,RGB(255,0,0));<br />
return TRUE;<br />
}
this is this.
|
|
|
|
|
for first time, i'm able to find a different reply for this query.
"But your mind is very complex, very tricky. It makes simple things complicated. -- that's its work. And for centuries it has been trained for only one thing: to make things so complicated that your life becomes impossible."- Osho
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1"> --[V]--
|
|
|
|
|
in the message map, is it ON_WM_ERASEBKGND() ??
"But your mind is very complex, very tricky. It makes simple things complicated. -- that's its work. And for centuries it has been trained for only one thing: to make things so complicated that your life becomes impossible."- Osho
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1"> --[V]--
|
|
|
|
|
Exactly.
In the message-map:
ON_WM_ERASEBKGND()
In the header:
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
In the implementation:
BOOL CWhateverDialog::OnEraseBkgnd(CDC* pDC)
I am about to go eat some cake. Happy birthday to this!
this is this.
|
|
|
|
|
thanks for this technique.
|
|
|
|
|
i'll try this, anyhow anything from Mr Khan has always worked fine. so my 5 to you inadvance.
"But your mind is very complex, very tricky. It makes simple things complicated. -- that's its work. And for centuries it has been trained for only one thing: to make things so complicated that your life becomes impossible."- Osho
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1"> --[V]--
|
|
|
|