|
oliver_mak wrote: How do I fix this problem?
By trying my other three suggestions perhaps.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Hello
I have Visual studio 2005. I have created a Win32app project with a dialogbox containing a treeview control. As I would like to have the dialogbox in the client part of my window i have added the handle of WM_CREATE message in the MainWndProc like this :
switch (message)<br />
{<br />
HANDLE_MSG(hWnd, WM_CREATE, WndProc_OnCreate);
and I have wrote :
BOOL WndProc_OnCreate(HWND hwnd,LPCREATESTRUCT ct)<br />
{<br />
HWND g_hViewDir;<br />
g_hViewDir = CreateDialog(hInst, MAKEINTRESOURCE(IDD_SHOWDIR), hwnd, ShowdirDlgProc);<br />
if(g_hViewDir != NULL)<br />
{<br />
...<br />
}<br />
else<br />
return FALSE;<br />
return TRUE;<br />
}
No compilation error. When i launch the app the dialog does not appear. I have investigate and found that the error message comes out of the CreateDialog function and says : Error 1407 : Unknown window Class ????
Could someone help.
|
|
|
|
|
Check your linking into the Common Control library comctrl32.lib and calling InitCommonControlsEx[^] to initialize the library, finally also check your passing ICC_TREEVIEW_CLASSES as a flag so it knows to load the correct classes.
Gavin Taylor
w: http://www.gavspace.com
|
|
|
|
|
Thanks a lot that solved my problem. But in the documentation of InitCommonControlsEx it says that it is not necessary to use it if we use a manifest. In that case i do not understand.
|
|
|
|
|
Hi together,
I have a big problem. I hope somebody can help me:
I implemented a service that runs under the local system account and checks if any screen blanker is activated. I use the following code:
bool result = false;
SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, (LPVOID) &result, 0); This works fine on Win XP, but on Win 2000 the function always return true. It is a known bug according to article number 318781 on MSDN.
The suggested workaround is to look for the entry "SCRNSAVE.EXE" under the registry key "HKCU\Control Panel\Desktop" using the following two lines:
RegOpenKeyEx(HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, KEY_READ, &hKeyScrSave);
RegQueryValueEx(hKeyScrSave, "SCRNSAVE.EXE", NULL, NULL, (LPBYTE) szData, &dwData); Now the problem arises: As my service runs under the local system account, access to "HKEY_CURRENT_USER" is redirected to "HKEY_USERS\.DEFAULT".
So the result refers to the logon screen saver, which is (usually) always activated. But I only want this result if no user in logged in.
Therefore my question: Does anybody has a solution, how to check if a screen saver is active under 2000 like SystemParametersInfo(SPI_GETSCREENSAVEACTIVE) does it for XP? An idea how to access data under "HKEY_CURRENT_USER" from the local system account would also be very valuable for me.
Thank you very much for any hints,
Marcus.
|
|
|
|
|
Two quick things - first SystemParametersInfo(...) does not use C++ types, so you should be passing the address of a BOOL (an int , or 4-bytes under 32-bit MS), not a bool (1-byte under 32-bit MS).
Second, I am pretty sure that screen savers run on a separate desktop, the "screen saver desktop". Search MSDN for information on Window Stations and Desktops for more information.
If I am correct, you might be able to determine which desktop is active, and from that determine if a screen saver is running.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Hi James,
thank you very much for your reply!
Concerning the bool/BOOL issue: I'm actually using a BOOL. In my message, however, I cut & pasted the code from MSDN, which seems to contain several bugs/typos Anyway, thanks for the hint.
Concerning the desktop issue: I think you are right. Some time ago I've read that the screen saver runs on another desktop. So I'll dig into that again
Thank you again,
Marcus.
|
|
|
|
|
khb wrote: SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, (LPVOID) &result, 0);
I think you want to check SPI_GETSCREENSAVERRUNNING instead.
khb wrote: Now the problem arises: As my service runs under the local system account, access to "HKEY_CURRENT_USER" is redirected to "HKEY_USERS\.DEFAULT".
See MSDN article Q168877 for an example.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Hi David,
I think that what I posted was correct. I want to check if a user has "installed" a screen saver so that I can expect that there is a change that it will start running somewhen. Anyway, I check if it is actually running, too.
The howto on Q168877 seems to be exactly what I was looking for, great!
Thank you,
Marcus.
|
|
|
|
|
Hi,
I am creating an array of pointers that point to unsigned char arrays like so
unsigned char* data[3];
where
data[0] = new unsigned char[256];
data[1] = new unsigned char[256];
data[2] = new unsigned char[256];
I now want to return this pointer array data from one function. How can I do that? Or what way could I return data[0], data[1] and data[2]?
Thanks for any help cause am a bit stuck here
|
|
|
|
|
You can't return an array - If you burry it in a stuct you can work around this. i.e.
struct MyData
{
unsigned char* data[3];
};
MyData Function()
{
MyData md;
return md;
}
Steve
|
|
|
|
|
Oh ok! Thanks.
I will call that function in a different class though. So do I have to define another struct (lets call it MyData') and then lets say
void callFunction
{
md'.data[3]=Class::Function;
...}
How would I go about getting data[0], data[1] and data[2] then? Sorry just a bit confused as its like arrays, pointers and structs and am quite new to this.
Thanks in advance for any help!
|
|
|
|
|
Code like this:
MyData d1, d2;
d1 = d2;
Copies dt.data[0] , dt.data[1] and dt.data[2] (and all the rest if any).
Steve
|
|
|
|
|
you'll have to create the MyData::operator = () member for this, otherwise, it will only copy the addresses, not the array contents...
|
|
|
|
|
The question said, "return this pointer array" - I believe it's the addresses that he wants copied - Although it wasn't clearly stated.
Steve
|
|
|
|
|
Stephen Hewitt wrote: Although it wasn't clearly stated
agreed
|
|
|
|
|
your code is incorrect because you return a local object...
>> You can't return an array
yes we can, by returning the pointer... it is exactly the same when you pass arrays as parameters to functions.
|
|
|
|
|
v2.0 wrote: your code is incorrect because you return a local object...
No I don't - I return a copy of a local object - This is fine. Returning a pointer or reference to a local object is where you get into trouble.
v2.0 wrote: >> You can't return an array
yes we can, by returning the pointer... it is exactly the same when you pass arrays as parameters to functions.
Returning a pointer is not the same as returning an array - A process called "decay" occurs and you lose the size info. With the code I gave (array in a struct) an array is returned and no decay occurs and the length is not lost - But the data is copied not referenced.
Steve
|
|
|
|
|
Stephen Hewitt wrote: A process called "decay" occurs and you lose the size info
Not just that, but you also effectively change the type of the variable - an array is generally a valid location in memory (whose location cannot be changed easily), while a pointer can point to a valid location in memory. (This difference is also important when optimizing code.)
Peave!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Since you have to put the returned array in an array anyway, you can create this "reception" array before calling the function and pass it as a parameter to the function. I think this is a much better solution than trying to "return" it, even burried in a struct.
~RaGE();
|
|
|
|
|
ahhhh, good ol' C runtime
Well done Mr "Diplomacy" ;P
|
|
|
|
|
V2.0 is too much for me. I'll go back to V1.6.
~RaGE();
|
|
|
|
|
v3.0 release date is set to 02/05/06... don't forget it
|
|
|
|
|
Hi i am doing a project and am making a tetris game in C++ V 6.0. So far i have crated the main menu screen... now i need to draw out a grid and start to make shapes fall... it seems i dont know how to do this. Does anyone have any tips or any codes i could have a look at??
Cheers for the help guys!
|
|
|
|
|
The best option is probably to create a custom control and do all the drawing yourself. Take a look at the miscellaneous controls on this site to see how to make one (it is not easy). Then to make the shapes fall, I think a timer will do that.
|
|
|
|