|
Hello!
The general code for displaying a dialog is as follows: you need to declare a variable whose type is the dialog you want to display. You then need to call the DoModal() function of the dialog. This is assuming that when you clicked 'New Form' in VC++ 6.0 that you left the base class as 'CDialog'. To check your base class open up the .h file of your dialog box (e.g. Dlg2.h) and look at the declaration for the dialog. It should look something like this:
<br />
class CDlg2: public CDialog<br />
If you see 'CDialog' then your dialog's base class is 'CDialog' and you can follow my instructions above. Here is a code sample of what you wanted to do:
<br />
void CDlg1::OnBT1()
{<br />
CDlg2 myDialog;<br />
<br />
myDialog.DoModal();<br />
<br />
}<br />
<br />
void CDlg1::OnBT2()
{<br />
CDlg2 myDialog;<br />
<br />
myDialog.DoModal();<br />
<br />
}<br />
Hope that helps! If you don't know anything about message handlers or just want to know how to add one, please ask. In the meantime you could take a look at http://www.codeproject.com/dialog/#Beginners[^] for some great articles on getting started with Dialogs.
Sincerely,
Alexander Wiseman
Est melior esse quam videri
It is better to be than to seem
|
|
|
|
|
Thankyou very much! This has solved my problems!
I will also take a look at the link you provided!
Have a nice day!
$TELOPHASE$
|
|
|
|
|
Try reading about the subject!
This[^]article should give you an idea about what you want to accomplisch...
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
Hello,
My question today has to do with how you should implement DC s. I am having some debug assertions caused by an apparent DC misusage and would therefore like to know if there is anything wrong with my implementation.
Would you say it is alright to have a global pointer/object (in, say, a custom control's class) for a DC which is used by any painting (graphical output) functions. For example, consider the following:
class CustomControl : public ...
{
private:
CDC *pDC;
.
:
.
};
CustomControl::OutputLine(char *szStr)
{
BeginOutput();
.
:
.
EndOutput();
}
CustomControl::OnPaint(LPPAINTSTRUCT lpPaint)
{
BeginPaint(lpPaint);
BeginOutput(lpPaint->hdc);
.
:
.
EndOutput();
EndPaint(lpPaint);
}
CustomControl::BeginOutput(HDC hdc )
{
if(!DCHandle)
{
DCHandle = new CDC;
ASSERT(DCHandle != NULL);
if(!hdc)
DCHandle -> Attach(GetDC() -> GetSafeHdc());
else
DCHandle -> Attach(hdc);
.
:
.
}
CustomControl::EndOutput()
{
ASSERT(DCHandle != NULL);
ReleaseDC(DCHandle);
DCHandle->Detach();
delete DCHandle;
DCHandle = NULL;
}
Now imagine a worker thread running ,which invokes OutputLine , above defined, multiple times per second. The debug assertion happens everytime the control has to repaint (OnPaint invoked), whilst it is outputting.
Any ideas on what is happening here and on how to solve this?
Thank you very much.
David
[EDIT:] By the way, this particular problem is occurring inside a worker thread, which is not derived from CWinThread but interacts with several controls.
|
|
|
|
|
Which ASSERT is triggerd?
IIRC, DC's cannot be shared between threads. Have you tried the same code in a single threaded application?
--
Ich bin Joachim von Hassel, und ich bin Pilot der Bundeswehr.
Welle: Erdball - F104-G Starfighter
|
|
|
|
|
Jörgen Sigvardsson wrote:
Have you tried the same code in a single threaded application?
Yeah, that is why I know this is a multithreading issue.
Jörgen Sigvardsson wrote:
Which ASSERT is triggerd?
Somewhere in one of MFC's sources (I believe WinGDI , among others)
Well, I have tried to correct this in the following way:
-- BeginOutput will not return until DCHandle has not been freed by EndOutput ;
CustomControl::BeginOutput(...)
{
while(DCHandle!=NULL);
.
:
.
}
-- this means that, not only the implementation has to be perfect (there has to be a correct initialisation/destruction of the DC handle), but also the thread will perform one graphical output operation at a time...
What do you think of this?
David
|
|
|
|
|
dNimrod#X wrote:
What do you think of this?
I think a critical section or mutex would be better. 1) it would be safe and not prone to race condition errors, 2) it would save a lot of CPU usage. How often do you paint and how often does the different threads fight for the DC? If the thread paint requests are done often but not often at the same time, a spin lock could be advantageous. A spin lock is basically a thread safe while(locked); synchronization feature. I believe there are a bunch of spinlock implementations on this site alone.
But anyway, I would proceed with a thread safe way. Problems will occur otherwise, it's just a matter of time and coincidence.
--
Ich bin Joachim von Hassel, und ich bin Pilot der Bundeswehr.
Welle: Erdball - F104-G Starfighter
|
|
|
|
|
Anybody knows, where i can find a free data mining application, some kind of demo or free trial, or maybe coding of data mining algorithm. Thanks.
<italic>Work hard and a bit of luck is the key to success.
|
|
|
|
|
Hello,
I am having problems with ShellExecute,
and it is probably my misunderstanding
of how it works.
I have a batch file called rmdir.bat:
@echo off
rem - rmdir.bat
rmdir .tempdir
and if I use ShellExecute(NULL,"open","rmdir.bat",NULL,NULL,SW_HIDE),
the .tempdir is removed. But if I change my batch file to read,
@echo off
rem - rmdir.bat
rmdir < $1
and change ShellExecute to
ShellExecute(NULL,"open","rmdir.bat",".tempdir",NULL,SW_HIDE),
the .tempdir is not removed.
I thought that lpParameters (i.e., ".tempdir" in this example) would get passed
to rmdir.bat, but apparently it does not.
Anybody know what I am missing here?
Thanks,
Murrah Boswell
|
|
|
|
|
I think your batch file is wrong.
rem set to off when the program works.
@echo on
rem use %1 not < $1
rmdir %1
rem stop batch program to see results
pause
|
|
|
|
|
This is correct. There's nothing wrong with your ShellExecute call
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
That was it! Been a while since I had tro write a batch file!
Thanks for your help,
Murrah Boswell
|
|
|
|
|
The classic slider controls is not "exact". When you clisc it it goes one thick further, is there any way to go exacty where i clicked it ?
|
|
|
|
|
I used spy++ to find out text I want to scrape from an app is sent to messages like this:
EM_REPLACESEL lpszReplace:0012f050("Text I want to scrape")
How do i scrape that? I tried examples of text scrapeing that use wm_gettext, but that doesn't work in this case.
|
|
|
|
|
Hi,
Have a look at this excellent article: http://www.codeproject.com/system/hooksys.asp[^].
This article explains about hooking and about how you can intercept messages from other applications. If this wasn't what you were looking for, please explain a little more and I will try and help you.
Sincerely,
Alexander Wiseman
Est melior esse quam videri
It is better to be than to seem
|
|
|
|
|
Hi, thanks i have seen those. I'm looking for something that shows the bare minimum code for a dll and application needed to record all the messages an application sends to an object.
I simply want to use this to scrape data from an application. Any ideas?
Thanks!
|
|
|
|
|
Hi,
Okay, I think I understand what you are trying to do right now. I will try and put a quick something together to make sure this works, but if you want to play around with it take a look at this link: http://www.codeproject.com/system/KeyHook.asp[^]
This project implements a keyboard hook, but I think what you want to do can be accomplished with a similar approach. Conceptually, what you have to do is install a hook with SetWindowsHookEx (I think with the first parameter as WH_GETMESSAGE), then, in your hook message handler, you need to look at each message and see which one is the message you want to get to the specific control you want to get it from. Then, once you have identified that message, all you need to do is grab the data from the LPARAM or WPARAM of the message.
As I said, I'll try and pull something together to see if this works. Let me know if you have any more questions.
Sincerely,
Alexander Wiseman
Est melior esse quam videri
It is better to be than to seem
|
|
|
|
|
WM_GETTEXT cannot work across process boundaries. Notice the 'lParam' parameter is a pointer to a buffer. This buffer will only be valid in the calling process.
What you need to do is put the WM_GETTEXT code in a DLL and have that DLL load into the target process' memory space. A common technique for doing this is using any type of hook via SetWindowsHookEx().
Bikram Singh
|
|
|
|
|
Hi
I made a sample Win32 Console program to know if the VC++ debugger will detect memory leaks in Win32 apps:
Code:
#include "stdafx.h"
int main(int argc, char* argv[])
{
printf("Hello World!\n");
char* ch=new char[100];
return 0;
} this shows a clear 100 bytes memory leak
After the program ends .. the debugger did not notify me about any memory leaks
But when making a Win32 Console program with MFC Support and try the same sample I get this :
Detected memory leaks!
Dumping objects ->
H:\Try\memLeakMFC\memLeakMFC.cpp(39) : {56} normal block at 0x002F2AA0, 100 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
Object dump complete.
How can I make the debugger detect Win32 apps memory leaks ?
Is there any other way to do it ?
|
|
|
|
|
Check the beginning of a typical cpp-file in a MFC-project, you'll see:
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
new is replaced by DEBUG_NEW when _DEBUG is defined. You can read about DEBUG_NEW on MSDN.
One easy way to get this functionality is to develop your console application in a MFC-enabled project, and when finished and tested, create a new console application and move the code over.
The best way to avoid leaks, however, is to make sure that each new is matched to a delete while developing. Then you won't need any special tools.
|
|
|
|
|
|
Hi, I want to know how do I store all of the list box items into Access Database file?
Thanks
|
|
|
|
|
get the string and list box and save in database . Find how to save in database in the database section here at code project
Work hard and a bit of luck is the key to success.
|
|
|
|
|
Hi, has anybody downloaded YM on Win 98. I was surprised to find out that YM changes the look of the "connect dialog" of IE when it wants to connect. I think YM used XP theme. But I thought that it isn't possible in Win 98. How was this done?
|
|
|
|
|
Hi, has anybody downloaded YM on Win 98. I was surprised to find out that YM changes the look of the "connect dialog" of IE when it want's to connect. I think it used XP theme. But I thought that it isn't possible in Win 98. How was this done?
|
|
|
|