|
Well then that's the problem. MFC stores handles in Thread Local Storage, so they aren't available from another thread. It's not a good idea to update the UI from another thread anyway (http://www.codeproject.com/csharp/begininvoke.asp[^]. I'd suggest posting a message to the UI instead (using PostMessage) and handling the message there.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
hi all,
I have followed the tutorial in this site about how to add items in the context menu.
But I don't know why I integrate it with another sample code, which is about cascading menu, the explorer.exe halt.
The problem happens when I rightclick on some empty spaces (not on files / folders) or the desktop.
Am I missing some controls to the context menu for that, besides files / folder?
What should I do?
Thank you very much
|
|
|
|
|
Alright I'm alittle new to this whole business and was wondering if I could get some help adding code to an existing project. I already have most of the code that needs to be added I'm just not quite sure what specifics need to be edited.
void CMFToolbar::SetOpenLoadProxy()
{
const char* conn_name="DefaultConnectionSettings";
const char* proxy_full_addr = "localhost:5115";
INTERNET_PER_CONN_OPTION_LIST list;
DWORD flag ;
if ( InternetGetConnectedState ( &flag, NULL ) )
{
if ( flag & INTERNET_CONNECTION_PROXY )
{
SetDefaultProxy();
}else
{
DWORD dwBufSize = sizeof(list);
// Fill out list struct.
list.dwSize = sizeof(list);
// NULL == LAN, otherwise connectoid name.
list.pszConnection = (LPTSTR)conn_name;
// Set three options.
list.dwOptionCount = 3;
list.pOptions = new INTERNET_PER_CONN_OPTION[3];
// Make sure the memory was allocated.
if(NULL == list.pOptions)
{
// Return FALSE if the memory wasn't allocated.
OutputDebugString("failed to allocat memory in SetConnectionOptions()");
}
// Set flags.
list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
list.pOptions[0].Value.dwValue = PROXY_TYPE_DIRECT |
PROXY_TYPE_PROXY;
// Set proxy name.
list.pOptions[1].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
list.pOptions[1].Value.pszValue = (LPTSTR)proxy_full_addr;//"http://proxy:80";
// Set proxy override.
list.pOptions[2].dwOption = INTERNET_PER_CONN_PROXY_BYPASS;
list.pOptions[2].Value.pszValue = "localhost; 127.0.0.1";
// Set the options on the connection.
InternetSetOption(NULL,INTERNET_OPTION_PER_CONNECTION_OPTION, &list, dwBufSize);
// Free the allocated memory.
delete [] list.pOptions;
InternetSetOption(NULL, INTERNET_OPTION_SETTINGS_CHANGED, NULL, 0);
InternetSetOption(NULL, INTERNET_OPTION_REFRESH , NULL, 0);
}
}
The following code is code I was given that will apparently scan a properties file for two specific fields. I know I need to add the code to open the file but I'm not sure what I would need to do after that?
char* whitespace_ltrim(char * pszSource)
{
char* cp = pszSource;
if (cp && *cp) {
while (isspace(*cp)) ++cp;
if (cp != pszSource) memcpy(pszSource, cp, (strlen(cp)+1)*sizeof(char));
}
return pszSource;
}
char* whitespace_rtrim(char* pszSource)
{
char* cp = pszSource;
if (cp && *cp) {
int bNonSpaceSeen = 0;
/* check if string is blank */
while (*cp){
if (!isspace(*cp)) bNonSpaceSeen = 1;
++cp;
}
if (bNonSpaceSeen){
--cp;
/* find last non-whitespace character */
while ((cp >= pszSource) && (isspace(*cp)))
*cp-- = '\0';
}
else{
/* string contains only whitespace characters */
*pszSource = '\0';
}
}
return pszSource;
}
char* whitespace_trim(char* pszSource) {
return whitespace_ltrim(whitespace_rtrim(pszSource));
}
/* psuedo code for reading a properties file */
void load_properties(void* config, char* file) {
char *name = NULL, *value = NULL, *eq_idx = NULL;
while( 1 ) {
/* get the next line */
char* line = NULL;
line = whitespace_ltrim(line);
if ( line != NULL && *line != '#' && (eq_idx = strchr(line, '=')) != NULL ) {
*eq_idx = '\0';
name = whitespace_trim(line);
value = whitespace_trim(eq_idx+1);
if ( strcasecmp("openload.proxy.host",name) == 0) {
/* strcpy(config->proxy_host,value); */
}
else if ( strcasecmp("openload.proxy.port",name) == 0) {
/* strcpy(config->proxy_port,value); */
}
}
}
}
|
|
|
|
|
even if today is still thursday ... it feels like a bad friday.
(using Visual Studio.net 2003 )
I derived a CStatic class and want to use it in my dialog.
so I do this :
in the dialog header :
#include "myStatic.h"
CMyStatic m_MyStatic;
in the source file :
DDX_Control(pDX, IDC_MY_STATIC, m_MyStatic);
The dumb question is, it can't go in the create functions, I need to do something there; just after the control is created to get and modify the static text.
Can I have a WM_CREATE handler in a CStatic ? or where can I have a method in my class after the control is just created ?
Thanks a lot.
Max.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
But.... Why do you use DDX_Control ?? You cannot use both DDX_Control and Create together.
Can't you simply override the Create function (and so you will be able to send your own parameters also) and then inside that function call Create of the base class ?
I always work like that...
|
|
|
|
|
If you want to handle the WM_CREATE message for the static control then you need to define your own CStatic-derived control, specify that class instead of CStatic associated with your control id and then handle the desired messages and overrides in your CStatic-derived class.
|
|
|
|
|
that's what I'm doing.
I have derived my own class from CStatic; inserted a CStatic in my dialog resource
used DDX_Control to do the automatic subclassing.
some code...
my CStatic derived class :
IMPLEMENT_DYNAMIC(CMyStatic, CStatic)
CMyStatic::CMyStatic()
{
}
CMyStatic::~CMyStatic()
{
}
BEGIN_MESSAGE_MAP(CMyStatic, CStatic)
ON_WM_CREATE()
END_MESSAGE_MAP()
int CMyStatic::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CStatic::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}
class CMyStatic : public CStatic
{
DECLARE_DYNAMIC(CMyStatic)
public:
CMyStatic();
virtual ~CMyStatic();
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
};
in my dialog class I have
DDX_Control(pDX, IDC_MY_STATIC, m_MyStatic);
and in the header :
CMyStatic m_MyStatic;
did I miss something obvious ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
that's what I'm doing.
I have derived my own class from CStatic; inserted a CStatic in my dialog resource
used DDX_Control to do the automatic subclassing.
some code...
my CStatic derived class :
IMPLEMENT_DYNAMIC(CMyStatic, CStatic)
CMyStatic::CMyStatic()
{
}
CMyStatic::~CMyStatic()
{
}
BEGIN_MESSAGE_MAP(CMyStatic, CStatic)
ON_WM_CREATE()
END_MESSAGE_MAP()
int CMyStatic::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CStatic::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}
class CMyStatic : public CStatic
{
DECLARE_DYNAMIC(CMyStatic)
public:
CMyStatic();
virtual ~CMyStatic();
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
};
in my dialog class I have
DDX_Control(pDX, IDC_MY_STATIC, m_MyStatic);
and in the header :
CMyStatic m_MyStatic;
did I miss something obvious ?
Thanks again.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Sorry. I didn't see that in the original post.
What exactly is not happening that you want to happen then?
|
|
|
|
|
should the OnCreate handler ( of ON_WM_CREATE ) be called when doing this ?
let's say that when I design my dialogs with the resource editor, I type in the text in the resource editor; now, in the code, when the CStatic ( my own derive class ) gets created, I want to get the text of the control and modify it ( and storing it in my derived class ).
I wanted to do that in the OnCreate, but it does not get called.
for example :
int CMyStatic::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CStatic::OnCreate(lpCreateStruct) == -1)
return -1;
GetWindowText( m_String );
DoSomething( m_String );
return 0;
}
thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
It's been a long time since I've seen this issue, but I don't think you can override create functionality the way you're trying to do it
In other words, when you place a control on a dialog template then the window for that control is created when the dialog is created and displayed. Then, you're having DDX subclass that window after it's already been created so the overridden creation functions (such as the WM_CREATE handler, OnPreCreateWindow, etc.) will never be called in yoru derived class.
You need to manually create the control (instead of placing it on the dialog template) via the Create or CreateEx function and then subclass it if you need to.
Let me know if you need any help doing this.
|
|
|
|
|
I know to do all of this, but my "users" don't want to have to do it manually.
I will continue looking for other options.
( thanks for the link in your other answer. )
max.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
|
Is it possible to grab audio data from sound car?
For instance, if I open a game emulator, the music in the game would be played through the sound card. ( Does it? Actually I'm not very sure! )
What should I do to grab the audio data that played by my sound card?
I'll appreciate your help, thanks!
|
|
|
|
|
I have a project which I want to build as a dll in one project workspace and as a static lib for another project workspace. can you somebody suggest ways to do this if it is possible? If I need to have two different project files, how do I create the second one in the same directory as the first one. and if it is possible to do with just a single .dsp file, what should I do in this .dsp file? Thanks in advance.
|
|
|
|
|
I would recommend having separate .dsp files. You can put them both in the same workspace (.dsw ).
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
You can use with VC6 'Configurations' under 'Build' menu.
|
|
|
|
|
Hello everyone, I have created an activex control using VC.net, the control works fine if i use the activex test container, or a small vc program i wrote to test the control. But if i use it in vb it doesnt, the problem is when i try to call the SetTimer funtion. from what i can see, the hwnd value is Null when called from vb, i think it is something to do with vb been the container ?? but i am not sure... does anyone have any ideas, as the rest of the control works a treat, its just this one point...
Thanks in advance
LJ
|
|
|
|
|
I have a problem. I want to capture the character which is deleted in the application. Please let me know how capture the character.
Thanking you,
E.Veera Raghavendra
|
|
|
|
|
|
Actually i am developing screen reader software. In this application if user presses baca space in the msword or any application i want to catch that charcter and to be supplied to speech engine. Ex:
if following is the text in the application.
hello good morning every body.
i started deleting letter by letter g,n,i,n,r,o,m. now i want to know which character is deleted. Please let me know.
Thanking you,
E.Veera Raghavendra.
|
|
|
|
|
I'm not sure I understand your question...
So, you say you have Word (or another application) open and your application that is also open. The user write something in Word and then delete it. You want to retrieve in your application what the user has deleted ? Is that correct ?
It looks really strange to me... But ok there could be option like using hooks on Word inside your application (that will allow you to retrive all keys that are pressed in Word). But I don't have a lot of knowledge in that field. Take a look on this site, I think there are a lot of articles that cover this subject.
If it is not what you were asking for, then try to reformulate your question a little bit clearer
|
|
|
|
|
Actually i am using hooking technology. ya, i want what the user deleted. U r assumption is correct.
e.veera raghavendra
|
|
|
|
|
You can write a keyboard hook to do that. Look for SetWindowsHookEx Win32 API function.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I am trying to handle drawing a header control so that I can support
multi-line items. It tried both owner and custom draw but neither will tell
me the control is 'hot' when the mouse is over it. Everything is ok if I
revert back to standard drawing so the window styles must be right. Can
anyone suggest what is wrong?
Systems AXIS Ltd - Software for Business ...
|
|
|
|