|
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");
|
|
|
|
|
arbster wrote: Whats wrong with the example code I've written to do this?
What's wrong is that you are not looking at any return values. Functions return a value for a reason.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
... and even wronger is the missing usage of _T() for string arguments.
"My god... we're all gonna die!
Control yourself, general."
|
|
|
|
|
Thats not wrong if you're not concerned with Unicode.
Steve
|
|
|
|
|
True, but is quite rare the code that escapes from Unicode today...
Nuclear launch detected
|
|
|
|
|
You opend your key so you must use of hkey on the RegDeleteValue
|
|
|
|
|
Hi All,
I have two ComboBox controls
{A(it has items like A1, A2 and A3)and
B (B has B1, B2 and B3)}
and one spin control (Z).
Now, my task is that when from control A, A1 is selected then full control B should be diabled. And for all others A2 and A3, B should get enabled.
This is how my code is:
m_CtrlA.SetCurSel(0);<br />
m_CtrlB.ResetContent();<br />
if (m_CtrlA.GetCurSel() == A1)<br />
{<br />
m_CtrlB.EnableWindow(FALSE); <br />
m_Spin.SetRange(0,1000); <br />
}<br />
<br />
else<br />
{<br />
m_CtrlB.EnableWindow(TRUE);<br />
}<br />
So, the problem is what this code is doing is that it is disabling the full m_CtrlB for every case. But I want to disable it for A1 only.
I would really appreciate if someone could help me.
Thanks a lot in advance
C++Prog
|
|
|
|