|
The thread proc needs to be defined correctly. For a member function it needs to be declared
static.
Mark
|
|
|
|
|
It looks like your using MFC, so why not use AfxBeginThread ? No big difference though . And are you sure MyThread->Thread is static?
:Gong: 歡迎光臨 吐 西批 :Gong:
|
|
|
|
|
thanks, that solves it
|
|
|
|
|
Hi All,
I posted my question earlier also but wasn't really satisfied. So, asking it again.
I have two comboboxes and if I select first item from first combobox then the second combobox should be disabled. And if I select any other items expect the first item from the first combobox, then the second combo box should be enabled.
I know how to disble and enable a window(using EnableWindow) but the problem I have is that I am not able to select that first item in the first combobox selecting which I disable my second combobox.
In the following code, I was trying it using GetCurSel and SetCurSel but it doesn't work. In the code, m_Au is the member of first combobox.
V is the first item in the first combobox of #define type.
m_C is the member of Second Combobox.
int nToken = m_Au.GetCurSel();<br />
m_Au.SetCurSel(0);<br />
if (nToken == V) <br />
{<br />
m_C.EnableWindow(FALSE); <br />
}<br />
else<br />
{<br />
m_C.EnableWindow(TRUE);<br />
}
I populated my second combobox dynamically based on the first combobox. So, I mean to say that they are related to each other.
I will really appreciate the help.
C++Prog
|
|
|
|
|
celllllllll wrote: I have two comboboxes and if I select first item from first combobox then the second combobox should be disabled. And if I select any other items expect the first item from the first combobox, then the second combo box should be enabled.
if (0 == m_Au.GetCurSel())
{
m_C.EnableWindow(FALSE);
}
else
{
m_C.EnableWindow(TRUE);
}
|
|
|
|
|
I really appreciate the answer but it doesn't work. It is disabling the second combobox for every selection in first combobox.
So, basically we can say the "if" statement isn't working.
Thanks for the help and reading the whole problem.
Thank You
C++Prog
|
|
|
|
|
Where are you calling this code - in response to a CBN_SELCHANGE message?
Are you still doing that m_Au.SetCurSel(0) ??
How about breaking it down...If you change the code as follows and put a breakpoint on the
"if" line....what is the value of CurSel when you select say, the second item in the list?
int CurSel = m_Au.GetCurSel();
if (0 == CurSel)
{
m_C.EnableWindow(FALSE);
}
else
{
m_C.EnableWindow(TRUE);
}
|
|
|
|
|
celllllllll wrote: m_Au.SetCurSel(0);
Why are you still doing it ?
:Gong: 歡迎光臨 吐 西批 :Gong:
|
|
|
|
|
May be you'd want to keep the selection back to the first item after a selection has been made, so you should put it in the bottom. eg :
int nToken = m_Au.GetCurSel();
m_Au.SetCurSel(0);
if (nToken == V)
{
m_C.EnableWindow(FALSE);
}
else
{
m_C.EnableWindow(TRUE);
}
m_Au.SetCurSel(0);
:Gong: 歡迎光臨 吐 西批 :Gong:
|
|
|
|
|
|
I dunno know why it doesn't work.
int nToken = m_Aux.GetCurSel();<br />
if (nToken == V)<br />
{<br />
m_C.EnableWindow(FALSE);<br />
m_Spin.SetRange(0,1000); <br />
}<br />
else<br />
{<br />
m_C.EnableWindow(TRUE);<br />
}<br />
<br />
m_Au.SetCurSel(0);
The code is disabling the complete second combobox but I wanted to disable it for V only. Don't know what to do
Thanks
C++Prog
|
|
|
|
|
Whats return value of EnableWindow for second combobox
|
|
|
|
|
To my fellow C++.NET Programmers, I thank you for reading my question.
I have somewhat of a pickle to deal with. A friend of mine might have asked the same question, but here it is:
I am writing code for a console project using a Microsoft Access database for reading information. The database consists of video titles, their types (DVD/VHS), and the amounts. The titles and types are being read as strings. My problem is that I cannot read the amounts as integers.
Here is some of my code:
The first three lines read the strings. The two that follow are nonexistent.
sID = (char*) ( (_bstr_t) pGetInfo->GetFields()->GetItem("Vid_ID")->GetValue() );<br />
sTitle = (char*) ( (_bstr_t) pGetInfo->GetFields()->GetItem("Vid_Title")->GetValue() );<br />
sFormat = (char*) ( (_bstr_t) pGetInfo->GetFields()->GetItem("Vid_Format")->GetValue() );<br />
iAmount = (???)<br />
iAvailable = (???)<br />
<br />
vVidList[iIndex].getVidID(sID);<br />
vVidList[iIndex].getVidTitle(sTitle);<br />
vVidList[iIndex].getVidFormat(sFormat);<br />
How can I read the information as integers in this case? Thanks!!!
Thank you for reading!
|
|
|
|
|
What type is pGetInfo?
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
_RecordsetPtr
Here is more of the code, including the code I already submitted:
CoInitialize(NULL);<br />
try<br />
{<br />
_RecordsetPtr pGetInfo("ADODB.Recordset");<br />
_bstr_t strMyDB("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=FinalDB.mdb");<br />
pGetInfo->Open("SELECT * FROM [Video];", strMyDB, adOpenKeyset, adLockOptimistic, adCmdText);<br />
pGetInfo->MoveFirst();<br />
while (!pGetInfo->EndOfFile)<br />
{<br />
sID = (char*) ( (_bstr_t) pGetInfo->GetFields()->GetItem("Vid_ID")->GetValue() );<br />
sTitle = (char*) ( (_bstr_t) pGetInfo->GetFields()->GetItem("Vid_Title")->GetValue() );<br />
sFormat = (char*) ( (_bstr_t) pGetInfo->GetFields()->GetItem("Vid_Format")->GetValue() );<br />
<br />
vVidList[iIndex].getVidID(sID);<br />
vVidList[iIndex].getVidTitle(sTitle);<br />
vVidList[iIndex].getVidFormat(sFormat);<br />
<br />
pGetInfo->MoveNext();<br />
iIndex++;<br />
}<br />
pGetInfo->Close();<br />
}<br />
catch (_com_error &e)<br />
{<br />
cout << (char*) e.Description() << endl;<br />
}<br />
::CoUninitialize();
What can I do without having to write two different sets of code: one for string, and one for integers?
|
|
|
|
|
|
As said by coffeeaddict, you just need to "itoa" the string, for example:
<br />
char* sAmount = (char*) ( (_bstr_t) pGetInfo->GetFields()->GetItem("Vid_Amount")->GetValue() );<br />
sAvailable = (char*) ( (_bstr_t) pGetInfo->GetFields()->GetItem("Vid_Available")->GetValue() );<br />
<br />
iAmount = itoa(sAmount);<br />
iAvailable= itoa(sAvailable);<br />
:Gong: 歡迎光臨 吐 西批 :Gong:
|
|
|
|
|
To both VuNic CoffeeAddict, I thank you guys for helping me out. I was expecting to read the items (amount and available) as integers directly, but I think this will do the trick. If I have any other news, I'll repost. Thanks a bunch!
As a friend said, "TOO GOOD!!!"
|
|
|
|
|
You are welcome Mr Bond
Code-Frog:So if this is Pumpkinhead. Time for him to run and hide. It's an interesting thought really.
|
|
|
|
|
I know how to initialize a brush or pen to a specific color, but I couldn't find any methods for changing the contents of a brush or pen once it has been initialized. In my application the user has to be able to change it, so simply creating a new variable isn't practical. I've been deleting the brush and then re-initializing it with the new color as you can see:
void CGameWin::ChangeBackgroundColor(COLORREF Color)
{
CurrentBackgroundColor = Color;
CurrentBackgroundColorBrush.DeleteObject();
CurrentBackgroundColorBrush.CreateSolidBrush(Color);
background_DC.SelectObject(CurrentBackgroundColorBrush);
}
Is there a better way to do this?
|
|
|
|
|
You can't change a brush, you need to create a new one. If this happens often enough, you could build a cache, I guess.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi. I am having a problem running the 'dt_dll' of windows platform sdk under windows 2000 SP4. It comes with a replacement ws2_32.dll (winsock2) that makes possible to trace winsock calls.
The problem is that this replacement of ws2_32.dll calls GetModuleHandleExA in kernel32.dll, by kernel32.dll does not have this entry.
Anybody knows what is (version?) the problem ?
Thanks a lot.
Juan Carlos Franzoy
|
|
|
|
|
GetModuleHandleEx is only supported on Windows XP and higher, not on Windows 2000 (see here[^]).
Check, if there's a version of the ws2_32.dll replacement available for Windows 2000. If not, you'll need to develop/test it on a machine with Windows XP or higher.
|
|
|
|
|
I'm trying to delete a value inside a specific key. Whats wrong with the example code I've written to do this?
<br />
<br />
HKEY hkey;<br />
RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Belkin\\Belkin 802.11g Wireless PCI Card\\1.0.0", 0, KEY_SET_VALUE , &hkey);<br />
RegDeleteValue(HKEY_LOCAL_MACHINE,"test");<br />
RegCloseKey(hkey);<br />
|
|
|
|
|
RegDeleteValue(hkey,"test");
|
|
|
|