|
Your eyes do deceive you... I wrote SetEnvironmentALVariable(string,string BOOL)....its my own function
Basically just updates the
HKLM\\System\\CurrentControlSet\\Control\\Session Manager\\Environment key.
|
|
|
|
|
Guinness4Strength wrote:
Your eyes do deceive you... I wrote SetEnvironmentALVariable(string,string BOOL)....its my own function
Fair enough! Those two little characters were hiding behind the bushes.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Yup, and if I ever get this thing into production, I'll change the name of the function to be more unique.
|
|
|
|
|
Your base assumption is invalid:
//cycle through entrys and add to registry
You only modified the environment block for your current process!
Calling SetEnvironmentVariable has no effect on the system environment variables. The user can add or modify system environment variables using the Control Panel. To programmatically add or modify system environment variables, add them to the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment registry key, then broadcast a WM_SETTINGCHANGE message. This allows applications, such as the shell, to pick up your updates. Note that environment variables listed in this key are limited to 1024 characters.
You really DO need to 'change the registry' yourself.
THEN broadcast the message and it should be picked up by other processes.
|
|
|
|
|
Upon closer inspection you will see that SetEnvironmentalVariable is my own function....
As I said in my original post, the variables are getting set in the registry correctly, I have already verified this.
|
|
|
|
|
If you are modifying the PATH, for example, make sure your registry is using the REG_EXPAND_SZ field type if that is appropriate.
I rechecked what we do, and we call RegFlushKey before closing the registry key and before calling the WM_SETTINGCHANGE. If you are not doing that already, it might help your situation.
|
|
|
|
|
Hi,
I'm having trouble with handle maps. I've been reading some information about the topic but I don't see how it applies to the problem I'm having.
Basically I have a class that represents a camera. It's a wrapper for API calls to set properties and capture images. The camera class also has a modeless dialog box as one of its members to display camera properties to the user. The dialog is created and exists for the lifetime of the camera class and there are function to show/hide it.
For some reason the following fails
<br />
bool MultipleCameraWrapper::SetShutter(int nShutter)<br />
{<br />
...<br />
this->m_pConfigDlg->m_nShutter = nShutter;<br />
this->m_pConfigDlg->UpdateData(FALSE);
}<br />
More specifically
CHandleMap* pMap = afxMapHWND(); returns NULL inside UpdateData(). Can someone tell me why and how to fix it?
|
|
|
|
|
Are you calling it from a different thread than the one that created it?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
|
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
|
|
|
|