|
Thanks for the tip. Unfortunately I had some problems using your method, but I did find an answer that works in my case. What I did was change the OnShowWindow message handler for all my panes and, depending on each pane, I changed the focus to the input box I needed. This way, just before the window is drawn, the input box gets focus, and I can do the whole thing within the pane's class itself, instead of externally. Thanks again.
"Ignorance is the sin of the many, whereas knowledge is the salvation of few."
Aanidaani
|
|
|
|
|
Is it possible to create a modeless dialog that does not
pop itself or owning application above all desktop windows ?
I tried following, but didn't work:
D->initiallyHidden=1;
D->Create(IDD,0);
D->SetWindowPos(NULL,0,0,0,0,
SWP_SHOWWINDOW|SWP_NOOWNERZORDER|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE);
I got some success with:
CWnd *w=GetForegroundWindow();
D->Create(...)
if(w)w->SetForegroundWindow();
but it makes dialogs parent application flicker.
|
|
|
|
|
My first thought is to use ShowWindow() instead of SetWindowPos() and play around with the parameter (SW_SHOWNOACTIVATE looks like the right one). You need to turn off the Visible style in the dialog resource, otherwise it will automatically be shown during the Create() call.
--Mike--
I'm bored... Episode I bored.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
I'm reading MSDN but am not really sure whats happening:
dbName = "";
size=128;
LPSTR psz = dbName.GetBuffer(size);
SO does this mean that I've fixed things so that I can copy somethig less than 128 bytes into dbName? SO if I just did dbName = "aaaaaaaaaaaaaaaaa" directly who takes care of the fact that dbName was zero bytes long ("" emoty) before?
When is one method better than another? Or --- when it is necessary to do the GetBuffer strategy?
|
|
|
|
|
Check out my C++ string classes[^] article where I cover CString in detail.
But to summarize, dbName.GetBuffer(128) makes sure that the dbName buffer is at least 128 characters long (allocating more space for you, if necessary) and returns a non-const pointer to the buffer. You can then use that pointer as if it were a normal C-style string.
When you call any other CString methods (such as the = operator), that pointer may become invalid because some CString methods delete/reallocate the buffer.
nss wrote:
SO if I just did dbName = "aaaaaaaaaaaaaaaaa" directly who takes care of the fact that dbName was zero bytes long before?
CString manages its own memory (except for when you explicitly take control of the memory with GetBuffer() ).
--Mike--
I'm bored... Episode I bored.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Will do. Many thanks! MFC is always surprising me....
|
|
|
|
|
can anyone tell me how to put the whole content of scrollview into one bit bitmap?by the way, I don't know the content of the window,is it difficult?
thanks
|
|
|
|
|
Shouldn't just create a compatible DC, a bitmap the size of the scrollview, select the bitmap into the DC, and then sending WM_PRINT to the scrollview work?
|
|
|
|
|
I want to check the registry to see if a certain key TestViewBox exists. If it does, then I want to delete it (so all the stuff under it vanishes too - correct? ). Then I want to recreate it, and put in fresh entries under that key (a subkey and then values).
I'm thinking:
LONG res = RegOpenKeyEx(keyHandle1, "TestViewBox",
0, KEY_ALL_ACCESS, &keyHandle2);
if (res)
{
RegCreateKeyEx(keyHandle1, "TestViewBox", 0, "",
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
&keyHandle2, &disp);
RegCreateKeyEx(keyHandle2, "MyTestApp", 0, "",
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
&keyHandle3, &disp);
RegSetValueEx(keyHandle3, NumberOfBoxes,
0, REG_DWORD, (BYTE*)&numberOfBoxes, sizeof(DWORD));
{
Of course I will be checking the returnvalues from each registry function....
|
|
|
|
|
If RegOpenKeyEx does not fail it means that the key exists. You can then delete it with RegDeleteKey
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Use ::RegDeleteKey(). On Windows W9X, this deletes this key, subkeys and values. But on W2K/NT/XP, it doesn't, you have to delete the subkeys yourself (recursive key deletion before you can delete this key).
PS : be sure to release the key handles as well. Like a lot of developers, you seem to mix all together and reuse handles without freeing them first.
|
|
|
|
|
RegOpenKeyEx(HKEY_CURRENT_USER, "Software",
0, KEY_ALL_ACCESS, &keyHandle1);
LONG res = RegOpenKeyEx(keyHandle1, "MyCompany4",
0, KEY_ALL_ACCESS, &keyHandle2);
if (!res)
{
res = RegOpenKeyEx(keyHandle2, "MyApplication4",
0, KEY_ALL_ACCESS, &keyHandle3);
}
SO is this good? Am terrified I might erase the "SoftWare " key or something and destroy myself!!! So I need to know if its safe first....
if (!res)
{
res = RegDeleteKey(keyHandle2,"MyApplication4");
}
if (!res)
{
res = RegDeleteKey(keyHandle1, "MyCompany4");
}
RegCloseKey(keyHandle1);
RegCloseKey(keyHandle2);
RegCloseKey(keyHandle3);
(check res ) and Open the software key again and write the new subkeys.....
|
|
|
|
|
I would replace this :
if (!res)
{
res = RegDeleteKey(keyHandle2,"MyApplication4");
}
if (!res)
{
res = RegDeleteKey(keyHandle1, "MyCompany4");
}
RegCloseKey(keyHandle1);
RegCloseKey(keyHandle2);
RegCloseKey(keyHandle3);
with this :
if (!res)
{
RegCloseKey(keyHandle3);
RegDeleteKey(keyHandle2,"MyApplication4");
}
RegCloseKey(keyHandle2);
res = RegDeleteKey(keyHandle1, "MyCompany4");
RegCloseKey(keyHandle1);
Don't use the same res variable for all keys. Add braces to combine the cases, instead of putting them sequentially.
|
|
|
|
|
Thank you so much for the pointers....
|
|
|
|
|
I recently integrated an installer/uninstaller into my program (third party) and unfortunately calling GetCurrentDirectory and SetCurrentDirectory for loading and saving files points to C:\Documents and Settings\... I need all the files to be saved and loaded from the directory in which the .exe is located in. Is there a similar function (Win32) to GetCurrentDirectory which would get the application path eg. C:\Program Files\My Application\...exe?
|
|
|
|
|
GetModuleFileName does the job
modified 12-Sep-18 21:01pm.
|
|
|
|
|
char szPath[MAX_PATH];
GetModuleFileName(NULL, szPath, MAX_PATH);
-Dominik
|
|
|
|
|
|
Hi all,
I'm trying to use an OLE automation server from within an NT service. I wonder if that's possible at all.
Any hints welcome...
Paul
|
|
|
|
|
Any API is there to find out wheather the system is locked or not .
|
|
|
|
|
Can anyone help me to find a function that counts the number of directories?
I've tried it with the _findnext function but obviously it only works for counting the number of files and not the directories.
Thanx a lot!
Kind regards,
Geert
|
|
|
|
|
look at the definition of struct _finddata_t the attrib member
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
Does this also work for directories?
Thanx,
Geert
|
|
|
|
|
yes, look at the MSDN, it says
_A_SUBDIR
Subdirectory. Value: 0x10
Or use FindFirstFile
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
Imagine the following situation: I pass the address of
an integer varialbe of process A to process B, and have
process B to write a value to this address.
1> would an Access Violation exception be DEFINITELY
raised?
2> if process B happens to have a non-constant variable
(i.e. writable) locating at the same address as the one
passed to it, would an AV exception be raised? if not,
does that mean process B would simply change its own
variable value?
Thanks a lot!
Wenrich
|
|
|
|
|