|
Hi everybody, i need your help. Im trying to change the desktop wallpaper, but i must use the IActiveDesktop interface, and i dont know what files i must include in the header, in the msdn help, they tell me, that i must include shlobj.h but with that it doesnt work. If some body can help me i will be gratefull.
|
|
|
|
|
|
|
|
Hi,
I'm sharing an object between 2 threads and I need to synchronize it. The following is a model of my code:
<br />
class SynchronizedObject<br />
{<br />
<pre>SynchronizedObject()
{<br />
InitializeCriticalSection(&m_ThreadSynch);<br />
}<br />
<br />
CRITICAL_SECTION m_ThreadSynch;<br />
void Lock()<br />
{<br />
::EnterCriticalSection(&m_ThreadSynch);<br />
}<br />
void Unlock()<br />
{<br />
::LeaveCriticalSection(&m_ThreadSynch);<br />
}</pre><br />
<br />
void A()<br />
{<br />
Lock();<br />
B();<br />
Unlock();<br />
}<br />
<br />
void B()<br />
{<br />
Lock();<br />
Unlock();<br />
}<br />
};<br />
For some reason when I call A() my code doesn't lock up. Am I using the Critical Section incorrectly? Or does it check which thread is trying to enter the critical section and allows the same thread to enter it multiple times (which I thought wasn't the case). What about Mutexes? Aside from synchronizing accross processes do they behave differently? What about Semaphores?
Note: I've also tried to just put a member object CCriticalSection synch; and call synch.Lock()/Unlock() where appropriate. Same result.
|
|
|
|
|
Critical sections block separate threads from entering the critical section, not the same thread.
None of the synchronization objects, near as I ever read, will block the same thread from entering them.
Mutexes behave differently because they can be 'abandoned'.
If the process owning a mutex exits before releasing the mutex, another process waiting for it will be rleased with the result WAIT_ABANDONED.
Semaphores are for controlling 'metered access' to an object.
Now, in your instance, if Thread 2 called B(), then Thread1 would not be able to enter A() until Thread2 was done processing B(). Likewise, if Thread1 entered A() first, then thread2 could not enter A() or B() until Thread1 was done with A().
|
|
|
|
|
|
If you want your thread to lock up, use a semaphore object and the WairFor... functions. They don't allow a thread to enter the critical section twice when the state of the Semaphore is non-signaled.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Thanks for your replies. I didn't want the thread to lock up so this is perfect, but I wanted to confirm that that's how it worked and I'm not missing some small part of code.
|
|
|
|
|
Hi,
How can I show hidden folders when calling SHBrowseForFolder function?
Thanks.
Lynsen
|
|
|
|
|
|
I need to create a source to the <targetdir>data.mdb in Installshield.
I'm thinking either a function call, or directly adding Registry entries(yuck)
Can anyone help?
|
|
|
|
|
You need to call the SQLConfigDataSource function:
BOOL bStat = SQLConfigDataSource(NULL,
ODBC_ADD_DSN,
"Microsoft Access Driver (*.mdb)",
szDSNName);
|
|
|
|
|
Thanks for the function, but I was hoping to do this in Installshield (I'm using version 6 for C++).
The users won't have Admin access, so it has to be setup when I install it.
The registry screen in IS only allows 1 key below HKLM. There's a bunch of Reg functions in the help I can try.
|
|
|
|
|
Hi All,
there's anybody who knows if there is a way to set the font style (size, stuff like that) in a CListCtrl item?
Thanks a lot!
cheers!
|
|
|
|
|
Use .SetFont() on the control. It is going to want a CFont, you can call CFont's CreatePointFont(), or if your feeling picky call CreateFont() with 14 arguments of font flexibility.
|
|
|
|
|
Thanks Mark!
works good!
cheers!
|
|
|
|
|
I'm trying to load up a GDI+ bitmap using a pathname, and it does not work.
Here is what I try to do:
Bitmap bitmap(L"Images\\picture.bmp");
What DOES work is:
Bitmap bitmap(L"picture.bmp");
i.e., if the bitmap is in the same directory as the program
Bitmap bitmap(L"C:\\Images\\picture.bmp");
i.e., providing the full path name from the C drive
However, I cannot load it up from the base directory of the program for some reason. The picture is, of course, in the folder, and it works if I specify the entire path name starting from C drive, but not if I attempt to start from the program's directory.
Help ??
Thanks
|
|
|
|
|
Just a guess, but try L".\\Images\\picture.bmp".
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Since you know that the image is in the Images folder that is in the folder of the app, you could use the GetModuleFileName to get the app's folder and then append the Images\\[imagename] to it.
|
|
|
|
|
Indeed, this is what I ended up doing. I guess it ends up being the same thing in the end.
|
|
|
|
|
Hi,
I use EnumResourceTypes & EnumResourceNames to get all the Resources of my multilanguage DLLs system, trying to translate the DLLs strings.
But I can’t get the strings of the dialogs (statics, group boxs, ...), menus, ..., and I don’t know how can I do it. May you help me?
Thanks in advance.
|
|
|
|
|
Kaworu2 wrote:
But I can’t get the strings of the dialogs...
That's going to be tricky. See this article for more.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hi,
Link doesn't works, I'll try it later, what's the article that I must see?
Thanks for reply.
|
|
|
|
|
Hi again,
Now it runs! I see this article yesterday, but I can do it works propertly, today I'll read it again.
Thanks, c u later
|
|
|
|