|
Hey Everyone
I was working on a Browser based ActiveX Control (MFC VC++ 6 SP5) for doing file transferring. I have an internal thread in the control that handles all the transferring and such. I would like to send messages back to the main dialog for display (logging). However, I'm unable to send a message from the thread that the Control catches. I can throw messages in the control and catch them.. I can throws messages in the thread and catch them in the thread, just unable to send a message from the thread to be caught by the control (COleControl class). I have done something similar in an App, but I used an AfxGetMainWnd()->PostMessage(...) when posting the message, since this is a control and there by being a dialog based app, How do I get the message back to the main control or main dialog class?
As a note, I used the "ON_REGISTERED_MESSAGE" macro to register a custom message mapping to a handler function. Is there any reason why this would cause a problem? It works in an .exe App.
Thanks for any help or suggestions
Rick Gavin
|
|
|
|
|
I am not quite sure that I follow your question, but I believe that you will want to look at the PostThreadMessage function.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I have tried PostThreadMessage with no luck.
I have an activex control, generated with the 'MFC ActiveX ControlWizard', which gives me an app class of type COleControlModule, the program is structerd as such.... The COleControl Creates the Dialog, which intern creates the Thread, which intern creates the Socket. The data from the socket needs to be displayed in the dialog.
COleControlModule (App)
- COleControl (Ctrl)
- - CDialog
- - - CWinThread
- - - - CAsyncSocket
How do I get a message from the CAsyncSocket derived class back to the COleControl or the CDialog? If this was an App and Not a Control, I could use AfxGetApp() or AfxGetMainWnd()->PostMessage(...) to get a handle back to the main thread. However, these reference doesn't seem to be working for me in a Control.
Thanks for any help.
|
|
|
|
|
When I add this to my stdafx.h:
#pragma once
#ifndef foo
#define foo
#pragma message( "************i should be seen once*****************" )
#elif
#pragma message( "************i should be seen a lot*****************" )
#end#pragma once
#ifndef foo
#define foo
#pragma message( "************i should be seen once*****************" )
#elif
#pragma message( "************i should be seen a lot*****************" )
#endif
if
all I see in the compiler is the first message? Shouldn't it print the top message once, then lots of copies of the second message?
What obvious mistake am I making /this/ time?
TIA,
Pete
|
|
|
|
|
sorry, that code should have read as follows:
#pragma once
#ifndef foo
#define foo
#pragma message( "************i should be seen once*****************" )
#elif
#pragma message( "************i should be seen a lot*****************" )
#endif
|
|
|
|
|
No, because stdafx.h is preprocessed only once. See the VC forum FAQ, I have a FAQ on how precompiled headers work.
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
Like the Google toolbar? Then check out UltraBar, with more features & customizable search engines!
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
|
|
|
|
|
Good Eyes
I first looked at that question and I could not see why it would be failing, then I see your response and realized he was doing it in the precompiled header.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Ok, I've just read the FAQ (thanks for that btw), but I'm still confused.
I selected "Not using pch" in the project settings, and created a new header file which contains the following:
#include "stdafx.h"
#include <streams.h>
#include <initguid.h>
#include <qedit.h>
#pragma once
#ifndef foo
#define foo
#pragma message( "************i should be seen once*****************" )
#elif
#pragma message( "************i should be seen a lot*****************" )
#endif
this file is <bold>#include'd by a few other headers.
But I'm still only seeing the first line
By my reasoning, the header should be (pre)processed at least twice, since I see the first line a few times. So what's going on? are the defines not persistent throughout the preprocessing?
I'm confused!
Thanks for any input,
Pete
|
|
|
|
|
I want to create a simple application that exists only as a dialog. Thats easy enough. But I want that dialog to be a tabbed dialog.
That seems like it should also be easy but I'm stuck. Does anyone have a hint on this should be done?
Ron
|
|
|
|
|
If ur using MFC, check out CPropertySheet and CPropertyPage ,
otherwise have a look at the PropertySheet and CreatePropertySheetPage function.
Cheers!
Marc
|
|
|
|
|
I should have indicated I knew how to use the property sheet but my problem is getting the property sheet into the dialog that you get when you create a dialog based application.
I can create a property sheet dialog on the fly but then my application shows that dialog, and when I dismiss it, the application dialog pops up. I want them to be one and the same.
Ron
|
|
|
|
|
Ron,
Create a modeless property sheet as a child of your dialog, and do this in the dialog's OnInitDialog() handler. I often use an invisible frame in my dialog's resource to position and size the property sheet. This lets me easily add other controls to the dialog, since I can see the exact location of the property sheet in the resource editor.
/ravi
Let's try putting "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
|
I think you should try to either:
- A: Change the base class of your CMyAppDlg from CDialog to CPropertySheet
- B: Check out this thread about how to make a CPropertySheet the child window of your dialog.
Cheers!
Marc
|
|
|
|
|
Look for some code that does the equivalent of FindFirstFile/FindNextFile for linux/unix.
OK I know this is not a VC++ question per se, but bear with me
If any of you who are out there and are familiar with unix/linux know this, any help would be appreciated !
|
|
|
|
|
Wohoo! First Linux question.
look at opendir, readdir and closedir
|
|
|
|
|
Wohoo! First Linux question.
Ha! I'm actually even replying from within linux using Konqueror !
look at opendir, readdir and closedir
OK you wouldn't happen to have any sample code lying around ?
The code is for porting the Visual Component Framework to linux. And this stuff specifically is to use in allowing file searches
Thanks !
|
|
|
|
|
Jim Crafton wrote:
OK you wouldn't happen to have any sample code lying around ?
The following sample code searches the current directory for the entry name.
dirp = opendir(".");
while (dirp) {
errno = 0;
if ((dp = readdir(dirp)) != NULL) {
if (strcmp(dp->d_name, name) == 0) {
closedir(dirp);
return FOUND;
}
} else {
if (errno == 0) {
closedir(dirp);
return NOT_FOUND;
}
closedir(dirp);
return READ_ERROR;
}
}
return OPEN_ERROR;
This is directly from readdir() documentation.
|
|
|
|
|
I want to get the text that just selected before activating(restore from sys tray) my application. For example; when I select any text in IE and restore my aplication. How can I do this
kozlu
|
|
|
|
|
If I'm understanding correctly, select the text in IE and use the Edit->Copy menu function to save it to the clipboard. Then, in your application, read from the clipboard into a buffer and have your way with it.
|
|
|
|
|
How are null values in database fields dealt with in C++ ADO #import msado15.dll.
I can retrieve data and display it if there are no nulls in the data.
The sql stops displaying at a null and will not display anything after it.
(It's as if the null acts as a string terminator )
Part of script...
while(!pRecordset->GetEndOfFile()){
for(int loop=0;loop<precordset->Fields->Count;loop++)
{printf("Name is '%s'\n",
(char*) ((_bstr_t) pRecordset->GetFields()->GetItem((short)loop)->GetName()));
printf("Value is '%s'\n",
(char*) ((_bstr_t) pRecordset->GetFields()->GetItem((short)loop)->GetValue()));
}
}
Any help here would be great!
|
|
|
|
|
GetValue (from FieldPtr) returns a _variant_t reference which basically just wraps a VARIANT. The case you are performing here is not safe because the VARIANT can be set to type VT_NULL or VT_EMPTY which cannot be cast to char*. To do this corretly, you need to check the type of GetValue (ie. VT_NULL or VT_EMPTY indicates a NULL value.)
|
|
|
|
|
Can you point me in the right direction for the use of VT_NULL or VT_EMPTY in an example or two...?
Searching the net I cannot see the wood for the trees at the moment!
Thanks
|
|
|
|
|
_variant_t varValue = pRecordset->GetFields()->GetItem((short)loop)->GetValue();
if (varValue.vt == VT_NULL || varValue.vt == VT_EMPTY)
{
printf("NULL");
}
else
{
printf((char*)(_bstr_t)varValue);
}
|
|
|
|
|
Hi there:
I am willing to learn how to write a custom pure API control (something simple for a start: e.g. equivalent of CStatic).
Could you give me an idea where to start or where to get more information on these kind of things?
Thank you.
A reasonable man adapts himself to the world. An unreasonable one persists, trying to adapt the world to himself. That is why all the progress in the world depends on the unreasonable men.
|
|
|
|