|
Okay that worked thanks. Now that I have a free-floating .c file, I thought I could just change main() to a regular function. This is what's happening now is that easy to figure out?
--------------------Configuration: 3daudio - Win32 Debug--------------------
Compiling...
3daudioDlg.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\3daudio\3daudioDlg.cpp(222) : error C2065: 'playmain' : undeclared identifier
Error executing cl.exe.
3daudio.exe - 1 error(s), 0 warning(s)
|
|
|
|
|
You are using "playmain" which has not been previously defined. You can't do that.
|
|
|
|
|
Hi,
I new to programming...Pls bare with me for this is really a basic question in pointers..
In my program I have a global variable
char *gz_Nos[10];
I need to assign some strings(like '000001','000002'...) to this array in one of my function and check the values in other function..
so I did as follows..ie my .cpp
char *gz_Nos[10];
mycalss::myclass(){}
mycalss::~myclass(){}
int myclass::func1()
{
char t_str[MAX_STRLEN];
for(i=0;i<2;i++)
{
wsprintf(t_str,"00000%d",i+1);
gz_Nos[i]=t_str;
}
return 1;
}
int myclass::func2()
{
char *sz_no;
int i=0;
.....
sz_no = "000001"
for(i=0;i<2;i++)
{
if(sz_no == gz_Nos[i])
{
MessageBox(0,"Error","Error",MB_OK) ;
return 0;
}
}
}
But here I couldnt see the value of gz_Nos[i] in func2..I am calling func1 first and then func2.And also in func1 if I display the value of gz_Nos[0] it displays '000002'. Where am I going wrong...
Thanks a lot.
|
|
|
|
|
Well for starters you are assigning a local variable (t_str) to your array of strings (gz_Nos), as soon as you exit the function, the compiler unwinds the stack and your left with a corrupt string. Try using something like char* t_str = new char[MAX_STRLEN], and make sure to call delete[] t_str when you no longer need it. Strings, memory and pointers are complicated beasts. Check out some good books, like Stroustrup's novel.
|
|
|
|
|
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.
|
|
|
|