|
The message for Combo box you handled in the parent dialog
i.e. CBN_SELCHANGE is called notification. In your project this notification message from child i.e. ComboBox to parent dialog is handled by the parent (Dialog which has the message handler). But when you derive the a class publically from the CComboBox class then you define the message handler in this new derive class for the notification message from the ComboBox and this method is called Message Reflection.
Now you will have to map your combo box with your newly
derived class through wizard which will defined an instance
of derive class to the parent dialog like...
class CSelChangeTestDlg:public CDialog<br />
{<br />
...<br />
private:<br />
CDerivedCombo m_MyCombo;<br />
....<br />
}<br />
<br />
void CSelChangeTestDlg::DoDataExchange(CDataExchange* pDX)<br />
{ <br />
CDialog::DoDataExchange(pDX);<br />
DDX_Control(pDX, IDC_COMBO1, m_MyCombo); <br />
...... <br />
}
Now the newly derivered class is self contained and you can this class for the customized behaviour in any project. You dont have to define the message handler again in the parent class/Window of the ComboBox because this defined in the derived class. you only need to map it with the Combo Box. If you need further help plz .....
Regard,
Nasir Maan
|
|
|
|
|
I have a Class (XClass) which has a private variable (Dialog*). It references to main dialog. So, the main dialog has same variables which were initializated before.
In the dialog I do something like that: varibleX.setParnert(this)
The problem is when I call one method, from the XClass, the Dialog´s variables lost their values.
it is an example how i do: ((CMyDlg*)pWnd)->NuevaTarea(strRecvd);
Which is my error?
el hombre arriesga su vida cada vez que elige y eso es lo que lo hace libre
|
|
|
|
|
I don't know exactly what's your problem, but since you're accessing the variables through a pointer (Dialog* ) you can modify them in any way. What you can do is making the parameters of your member-functions in XClass "const" . That way you won't be able to change the dialog variables directly. You can change e.g. definition of NuevaTarea() to something like that:
NuevaTarea(const CString& strRecvd);
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I´ll try to explain
I have a dialog(CSurSpoolerDialog) which has a public variable(server).
So, the Server has a private variable pWnd as CDialog* (which is a reference to parnert dialog (CSurSpoolerDialog))
I initilized the Server, Then I call server.setParnert(this)
So, The Server has a event (OnMessage)where I want to call a Dialog´s method ( ((CSpoolerSurDlg*)pWnd)->NuevaTarea(strmessage) )
All work fine, but when i debug the NuevaTarea all the dialod´s variables have lost them values. they have NULL (???)
it is more clearer?
|
|
|
|
|
I found the solution thanks you the any way
el hombre arriesga su vida cada vez que elige y eso es lo que lo hace libre
|
|
|
|
|
I try to make an active X calling an other active X, but I dont know how to do to make the active X I'm calling to be visible.
I don't know if I explain it as clearly as I should, but who can help me?
Thank you
|
|
|
|
|
Are you using MFC ? Well... anyway.. he activex will have and hWnd handle, just call the ShowWindow API and the control should display. If you're using MFC, you can use a method with the same name... that does the same thing.
Mauricio Ritter - Brazil
Sonorking now: 100.13560 MRitter
Life is a mixture of painful separations from your loved ones and joyful reunions, without those two we'd just be animals I guess. The more painful the separation, that much more wonderful will be the reunion - Nish
"Th@ langwagje is screwed! It has if's but no end if's!! Stupid php cant even do butuns on forms! VISHAUL BASICS ARE THE FUTSHURE!" - Simon Walton
|
|
|
|
|
Do I Have to create a CDialog to insert my active X into?
|
|
|
|
|
No.. you don't need to. Whatever method you use, the activex will always have an hWnd handle. Can you post the method you're using to create it ?
Mauricio Ritter - Brazil
Sonorking now: 100.13560 MRitter
Life is a mixture of painful separations from your loved ones and joyful reunions, without those two we'd just be animals I guess. The more painful the separation, that much more wonderful will be the reunion - Nish
"Th@ langwagje is screwed! It has if's but no end if's!! Stupid php cant even do butuns on forms! VISHAUL BASICS ARE THE FUTSHURE!" - Simon Walton
|
|
|
|
|
No, I haven't any hWnd...
My project is to create an Active X. So I've created this with Visual C++.
Then I want to insert in this project my other control Active X so I go to Project, Add to Project, Components and controls and I choose the component I want.
I've added methods to my project so I can call them from a tester...
On the call of one of this methods, i want to make the component I've inserted to be visible (it's a map)... How can I draw it?
I only have the about box and the property dialog in my project at the moment...
Thanks
dvlpt
|
|
|
|
|
I have created an MFC project through AppWizard which supports Active Documents. If I create a new document and insert an existing Word file, all looks fine. However, when I come to print preview, the preview window opens, but the document is actually printed to the printer.
I asked a while ago and no-one had any ideas of how to make it work, but I've come up with a few possibilities, and wondered if anyone might be able to help.
First possibility is to change the parameters to IPrint::Print() so that it uses the preview screen DC instead of the printer - anyone know how this can be done?
The second option is printing to a file, and then viewing the file. Any ideas on how I can view a "Print to File" file on screen?
Thanks in advance!
|
|
|
|
|
Can anyone suggest a good sample app that demonstrates multi-threaded graphics using VC++ and MFC? Trying to get a seperate thread working to handle dialog graphics animation. Thanks
|
|
|
|
|
find the "MTGDI" sample in the MSDN. it's the classic multi-threading sample: each thread controls a bouncing ball.
-c
|
|
|
|
|
Thanks, I forgot all about that one. I'll check it out.
|
|
|
|
|
How can I implement a class function, which can be run in separate thread
Example
class AudioIn
{
public:
AudioIn();
virtual ~AudioIn();
void StartProc();
HANDLE Thread;
DWORD m_ThreadID;
HANDLE hEvent;
};
AudioIn::AudioIn()
{
hEvent = CreateEvent(NULL,TRUE,FALSE,NULL);
Thread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)AudioIn::StartProc,NULL,0,&m_ThreadID);
}
Is it possible?
I'm creating console application in VC++.
Sorry for stupid question.
Tomaz
|
|
|
|
|
Yes. One your example, declare StartProc as a static public member function.
Kuphryn
|
|
|
|
|
How can I get few parameters into static class function?
Should I declare a structure
Thread = CreateThread(NULL,0,AudioIn::StartProc,declared-structure,0,&m_ThreadID);
or is there a simple way?
Thank you
Tomaz
|
|
|
|
|
You have to declare a structure and pass a pointer to it. There are some common problems regarding who owns this structure. Consider the following:
void foo()
{
data d;
CreateThread(...,&d,...)
} This seems OK and will probably work some times until it suddenly stops to do it. The reason is that, when the thread starts executing and access d , it is perfectly normal that foo has already exited, and d is no longer valid. So, you have to dynamically allocate the data:
void foo()
{
data* d=new data;
CreateThread(...,d,...)
} Now the problem is who deletes d ? The most reasonable choice is to let the thread delete the data:
MyThread(LPVOID arg)
{
data * d=(data *)arg;
...
delete d;
...
} This is almost perfect: you should take into account the rare case when the thread does not launch (due to insufficient resources, for instance):
void foo()
{
data* d=new data;
if(!CreateThread(...,d,...)){
delete d;
}
} That's it, hope it helps.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi Tomaz,
the problem is that CreateThread() is a c function...and c doesn't know anything about classes or virtual tables...
try this:
//---------------------------------------------------
void YourClass::AnyFunction()
{
// declarations
DWORD dwId;
// create the thread
CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)StartAddress,(LPVOID)this,0,&dwId);
}
DWORD YourClass::StartAddress(LPVOID lpParam)
{
// call the thread function
((YourClass*)lpParam)->ThreadFunction();
}
void YourClass::ThreadFunction()
{
...
}
//---------------------------------------------------
in the header you should declare the thread start procedure as follows:
static DWORD StartAddress(LPVOID lpParam);
..this should do it
|
|
|
|
|
It is working.
Thank you.
Tomaz
|
|
|
|
|
Hello,
Has anyone had problems catching WM_DROPFILES or EN_DROPFILES messages in a CRichEditView? I read msdn and believe I'm doing everything correctly but I can't seem to catch that message.. I have tried to set DragAcceptFiles(TRUE) in my Init() then in WindowProc() I try to catch WM_DROPFILES.. I have also added ENM_DROPFILES to the eventmask of my rich edit control and tried to catch EN_DROPFILES message and that hasn't worked either.. Here's what I've tried..
in WindowProc()
if (message == WM_NOTIFY)
{
if (((LPNMHDR)lParam)->code == EN_DROPFILES)
{...}
}
if (message == WM_DROPFILES)
{...}
Any ideas??
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
OnDropFiles should work. See Help under CWnd::DropFiles.
As far as I know, OnDropFiles is already impelemented in CRichEditView. So you have to override this function! That's why you never get notified, because the base installation alredy captured the message.
G. Steudtel
|
|
|
|
|
Would you tell me what API support to recognize CD-ROM status when i push the button eject on CD-ROM. Example it can recognize there are CD in CD-ROM or not.
|
|
|
|
|
char szBuffer[256];
mciSendString("status cdaudio media present", szBuffer, sizeof(szBuffer), NULL);
TRACE("szBuffer = ]%s[\n", szBuffer);
|
|
|
|
|
An alternative to DavidCrow's method:
#include <windows.h>
#include <sys/types.h>
#include <sys/stat.h>
bool drive_present(const char letter)
{
char nul_file[]="#:\\NUL";
nul_file[0]=letter;
DWORD error_mode=::SetErrorMode(0);
::SetErrorMode(error_mode|SEM_FAILCRITICALERRORS);
struct _stat st;
int res=_stat(nul_file,&st)==0;
::SetErrorMode(error_mode);
return res!=0;
} Use drive_present with the drive letter of the CD.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|