|
Hi,
I’ve been playing around with the Beginner’s DialogBox One tutorial on this site:
http://www.codeproject.com/dialog/dialogapptute.asp
and I was wondering how to get the text from a combo box. In the tutorial, we populated the IDC_TITLE combo box with some data(using the Data tab of the Combo Box Properties we accessed by right clicking the control):
Mr.
Mrs.
Dr.
Ms.
Then, for the combo box we added a member variable called m_nTitle, Category: Value, Type: int. I assume that when UdateData(TRUE) is executed, the integer position of the Title chosen by the user is transferred into m_nTitle. Is there a way to use m_nTitle to get the corresponding text from the combo box? I thought maybe if I added a Category: Control variable to IDC_TITLE, like m_controlTitle, then I could use m_controlTitle and m_nTitle to get the text, something like this:
CString strTitle;
strTitle = m_controlTitle.GetText(m_nTitle);
but there doesn’t seem to be a method of the ComboBox class that will do that.
In the tutorial, it says to do this:
CString strTitle;
int nIndex;
nIndex = GetDlgItemText(IDC_TITLE, strTitle);
but that just completely ignores the m_nTitle variable we created for the control.
|
|
|
|
|
Off hand, I would have to say try GetWindowText() and see if that will work for you.
Artificial intelligence is no match for natural
stupidity.
|
|
|
|
|
Hi,
Thanks for the response.
In the tutorial, this works:
CString strTitle;
int nIndex;
nIndex = GetDlgItemText(IDC_TITLE, strTitle);
The function you posted, GetWindowText() seems to be of the same form as GetDlgItemText() in that it completely ignores the value of the control, m_nTitle, that we already have.
I wondered what was the point of creating a variable to hold the value of the combo box control, if it wasn't going to be used. In turn, I wondered if there is a way to get the text from a combo box using the value of the control.
|
|
|
|
|
CComboBox::GetLBText(int nIndex, CString& rString) const;
"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!
|
|
|
|
|
I spent several minutes reading your sig and wondering what the heck you were trying to tell me before I noticed the line with the method.
Thanks for taking the time to help a beginner.
|
|
|
|
|
is there an ASM instruction (or opcode) that normalizes a double value (i.e. adjusts the exponent so the mantissa is .1xxxxx)
(And - if you don't mind - MSVC C++ inline assembly to normalize a double d )
we are here to help each other get through this thing, whatever it is Vonnegut jr.
sighist Fold With Us! || Agile Programming | doxygen
|
|
|
|
|
The real numbers are always stored in normalized form. The high-order bit of the mantissa is always 1 and it is not stored in the real*4 and real*8 formats.
More info: MSDN Library Visual Studio 6.0 - "IEEE Floating-Point Representation and Microsoft Languages".
Regards,
Andrzej Markowski
|
|
|
|
|
I have my dll injected into another process. Is there a way from that dll that I can tell what other dll's are mapped into the process, and be able to get the module handle to one of them? Any help is appreciated.
-Dev578
|
|
|
|
|
Dev578 wrote:
Is there a way from that dll that I can tell what other dll's are mapped into the process
EnumProcessModules() will do that for you. MSDN has a page called "Enumerating All Modules For a Process" that should have you the code you need.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
#include "witty-quote.h"
|
|
|
|
|
Hi dudes,
I want to change the default background color of SDI client are to black color. Actually it is in white color now. I mean I want to change the background color of View. In dialog box we have WM_CTLCOLOR. But I don't know what to do in view.
Thanks in advance for helping.
Promise.
If you have faith in the cause and
the means and in God, the hot
Sun will be cool for you.
|
|
|
|
|
|
How can this be done? I know how to change its background color but the text I can't get right...
|
|
|
|
|
This is one of the features I plan to add to FooButton[^]. Will let you know when the article is updated.
Meanwhile, you might want to check out (pun intended) some of the other owner drawn buttons here[^].
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hi,
I'm a beginner but I tried to figure it out for you. The following code doesn't work, but it's what I came up with, and maybe it will give you some ideas. I have a simple dialog box with a few controls and I added this function to the Dialog class(CCodeProject_Dialog2Dlg):
HBRUSH CCodeProject_Dialog2Dlg::OnCtlColor(CDC *pDC, CWnd *pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(pWnd->GetDlgCtrlID() == IDC_WIN98)
{
pDC->SetTextColor(RGB(255,0,0));
pDC->SetBkMode(TRANSPARENT);
}
return hbr;
}
How did you set the background color?
I can't believe the previous poster wouldn't help you. I clicked on the link he posted, and any of the author's of those button programs should be able to tell you how to do that.
Also, what's up with a programming forum that doesn't allow you to post indented code?
|
|
|
|
|
Is there anyone that has experiences with embedding WMF files to PDF without converting it to a raster image format?
Best regards,
A. Riazi
|
|
|
|
|
See the "Other enhancements" section here[^]. Hope this helps.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
This feature is part of another software. I want some source code/tutorial/article about it.
But thanks for your reply.
A. Riazi
|
|
|
|
|
My program has a debug assertion failure and it appears when i close the program the ASEERT failue dialog box is diplayed for a fraction of a second and disappears i am begining to sespect that this is due to the thread i create in my CView constructor in the thread there is an infinte loop and it never exits it postmessages in each second i never worked with THreads is it because the thread associated function never returns a value that i am receving the debug asserion failure ???
;)
|
|
|
|
|
Run the program under the VC++ Debugger and when the ASSERT occures press Retry to go into the debugger. Then look at the Stack Backtrace to find the cause.
Threads should be closed properly by your code. There are several waits to do this. One is to wait on an Event that you signal when your app is closing. Another is to force the thread to raise an exception. See: http://www.codeproject.com/threads/threadlibrary.asp [^] for a good example of this.
I have to wonder why your thread is posting a message once a second and what the thread is being used for. Threads shouldn't be an infinite loop. They should either Wait or Exit when processing is complete.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Neville Franks wrote:
I have to wonder why your thread is posting a message once a second and what the thread is being used for. Threads shouldn't be an infinite loop. They should either Wait or Exit when processing is complete.
First I wanted to make a thread to post a message each second because i was not satisfied with windows timer WM_TIMER messages i wanted to make a timer that is more or less accurate and won't be affected by other messages placed in the queue such as fast mouse cliks or so.
Neville Franks wrote:
Run the program under the VC++ Debugger and when the ASSERT occures press Retry to go into the debugger. Then look at the Stack Backtrace to find the cause.
The main problem is the Dialog box saying i have a debug assertion failure is displayed for a very short time and boom!!! it goes. i could not even see what the error message. let alone to push the button retry, i tired to capture the screen when the dialog box is displayed and it was to fast to do so by pressing the print screen key on the key board.
The debug assertion is caused when i close the window and especially for the first time i boot my comupter and run it from the VC++ editor, after the first build it occurs occasionaly
|
|
|
|
|
leyusha wrote:
Neville Franks wrote:
I have to wonder why your thread is posting a message once a second and what the thread is being used for. Threads shouldn't be an infinite loop. They should either Wait or Exit when processing is complete.
First I wanted to make a thread to post a message each second because i was not satisfied with windows timer WM_TIMER messages i wanted to make a timer that is more or less accurate and won't be affected by other messages placed in the queue such as fast mouse cliks or so.
This makes little sense to me. If your thread is using PostMessage() then you have no better gaurantee of the timer message being received at a specific time than WM_TIMER messages.
leyusha wrote:
The main problem is the Dialog box saying i have a debug assertion failure is displayed for a very short time and boom!!!
I would say you have a serious problem somewhere (not helpfull I know). I'd set a breakpoint in the debugger in the MFC ASSERT code that opens the message box. I'd also have a close look at the thread function. Maybe it is Posting to a Window that no longer exists. Multithreading is a complex area and should be avoided unless you have a very good understanding of how it all works.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Neville Franks wrote:
Maybe it is Posting to a Window that no longer exists
Yeap u are right i added a sleep function in the destructor of CView and was able to see the "ASSERT falure dialog box" and saw the file and line number with the assertion failure it seems that the CWnd::PostMessage() first checks to see if the CWnd is valid and hey it fails there.
Thanks a lot (now i have added a volatile bool variable to exit loop and a check to see if the CWnd is valid before posting a message and if not to exit loop)
|
|
|
|
|
Is there any function to draw draw a line with GDI? I can't seem it..:S
|
|
|
|
|
|
yeah i saw that function but it only lets me set 1 point.. not 2:s...
|
|
|
|