|
Generally you create a textbox as a child control, position it over the label and make it visible. When focus leaves the textbox, or it gets an enter press, your code pulls out the value, uses it, and hides the control, which is generally a member variable.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Thanks - The textbox sounds like just the ticket.
I still have a few questions.
1) My work so far uses C++ MFC. Must I (should I?) use CLR to get the textbox functionality?
Stan
|
|
|
|
|
*grin* that's one question.
No, if you did it using CLR, you'd just be adding CLR, at the core, your code would eventually do the same thing, and use the same control. MFC libraries do this sort of thing all the time.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
OK, Here is more than one:
0) I assume that this "textbox task" is strictly a programming task (as opposed to using resource editor for example). Is this correct?
1) If the answer to (0) is yes, what is the base class to start with for the textbox implementation? CEdit? Is there a derived class that is more suitable?
2) Can you point me at some sample code that uses a textbox for some similar task? If not, ...
3) Can you provide me with some "thread starters" that I can investigate in the Visual C++ index to MFC. I have looked under "textbox" and "control".
4) References I have:
a) Ivor Horton - "Beginning Visual C++ 2005"
b) Mike Blaszczak - "MFC with Visual C++ 5" (1997!)
Can you recommend any additional or better references?
Thanks for your help,
Stan
P.S. I don't know what the title "MVP" means, but I have chosen to translate it to "Most Valuable Person".
|
|
|
|
|
0 - yes
1 - I'd use CEdit. I'm not aware of any derived classes, actually
2 - If you google for samples that allow editing of an MSFlexGrid, or Chris has a grid for download on the site. The former will always use this method, the grid may, too.
3 - MSFlexGrid is a good googling point, at one stage there were lots of samples for doing this to that control.
4 - I recommend the MFC Answer Book, and perhaps MFC Unleashed.
MVP is a Microsoft award, it means Most Valued Professional, I think. CP does the same thing, but I don't get an MVP icon here, because I already have a staff icon
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
When your editing window gets focus you can go into a modal loop and process keystrokes and any
other user-input messages you need to handle. You can use the Caret[^] functions to handle the
insertion caret. Using a monospaced font makes this MUCH easier.
Here's an example shell for the message loop...
MSG Msg;
bool fEditing = true;
while (fEditing)
{
if (::PeekMessage(&Msg,0,0,0,PM_REMOVE))
{
::TranslateMessage(&Msg);
::DispatchMessage(&Msg);
if (Msg.hwnd != hMyWnd)
continue;
if (WM_KEYDOWN == Msg.message)
{
switch (Msg.wParam)
{
case VK_RETURN:
break;
case VK_HOME:
break;
case VK_END:
break;
case VK_PRIOR:
break;
case VK_NEXT:
break;
case VK_LEFT:
break;
case VK_RIGHT:
break;
case VK_UP:
break;
case VK_DOWN:
break;
case VK_DELETE:
break;
case VK_BACK:
break;
}
}
else if (WM_CHAR == Msg.message)
{
switch (Msg.wParam)
{
case 0x08:
break;
case 0x09:
break;
case 0x0D:
break;
case 0x0A:
break;
case 0x1B:
fEditing = false;
break;
default:
break;
}
}
else if (WM_KILLFOCUS == Msg.message)
{
fEditing = false;
}
}
}
|
|
|
|
|
Hello,
Has anyone of you managed to compile the LIBPNG[^] (1.2.15) to a DLL with MS Visual C++ 8.0 (2005)?
I'd be very thankful if you could share your .vcproj file with me.
|
|
|
|
|
VS2005 can load a PNG, why do you need LIBPNG ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Thank you for your reply.
I have a specialized library that is practically independent from the Platform SDK, and uses LIBPNG. I would like to include this library in my VS 2005 solution without modifying its code too much.
|
|
|
|
|
Hi folks,
I’ve got a problem getting a pointer to the active document from an MDI. The code below works fine for an SDI, but when I run the binary of the MDI it throws an unhandeled exception error upon trying to access data from the document. When I’m in the editor, however, the intellisense works just fine, ie, when I type ‘pDoc->’ it retrieves the right info from the current document. My question is whether I have to do any additional thing to get the statement below to work for MDIs and what that statement might be.
CMtxDoc *pDoc = (CMtxDoc *)
((CFrameWnd*) AfxGetApp()->m_pMainWnd)->GetActiveDocument();
CString szHold;
pDoc->m_nDim = 2; //exception thrown here
Thx,
Ralf.
ralf.riedel@usm.edu
|
|
|
|
|
How many document types are there?
Steve
|
|
|
|
|
One type only
ralf.riedel@usm.edu
|
|
|
|
|
What is the value of "pDoc" when the crash occurs?
Steve
|
|
|
|
|
For MDI isn't the active document associated with a view in an MDI child?
I'm assuming m_pMainWnd points to a CMDIFrameWnd...
CMDIChildWnd *pActiveMDIChild = ((CFrameWnd*) AfxGetApp()->m_pMainWnd)->MDIGetActive();
CMDIChildWnd *pActiveMDIChild = ((CMDIFrameWnd*) AfxGetApp()->m_pMainWnd)->MDIGetActive();
if (pActiveMDIChild)
{
CMtxDoc *pDoc = (CMtxDoc *)pActiveMDIChild->GetActiveDocument();
...
}
Mark
-- modified at 19:25 Tuesday 16th January, 2007
|
|
|
|
|
I have requiremnt where someone is passing me pointer to a buffer and I have to return value converted to that bufffer. I'm worried about buffer overrun. Here are two functions available for this..
_itoa(int value,char *buffer,size_t, int radix);
_itoa_s(int value,char *buffer,size_t, sizeInCharacters,int radix);
Here is my current function :
DWORD GetMessageSize(char *FileName, char *Size){
int intsize;
// do operation on file and get intsize
_itoa(intsize,Size,10);
return 0;
}
Since I don't know the size of buffer and if I use _itoa_s then how do I handle "sizeInCharacters" ?
Any help appreciated.
thanks
thanks
-- modified at 17:14 Tuesday 16th January, 2007
|
|
|
|
|
when you pass buffers as functions parameters, you usually pass a couple of arguments : the buffer address (thru the pointer) and the buffer size...
here, the function is definitely not well designed.
|
|
|
|
|
bs1977 wrote: Since I don't know the size of buffer and if I use _itoa_s then how do I handle "sizeInCharacters" ?
Short answer - you cannot use _itoa_s(...) correctly or in good faith without knowing the amount of valid buffer space you are passing telling it to use. toxcct 's response is the correct way to handle this problem, if you want to use _itoa_s(...) , otherwise switch to the plain old itoa(...) function.
Note that if you decide to change the function to accept the buffer size and you ever need to use Unicode or TCHAR code, be sure not to confuse the BYTE size of a buffer with its character size (sizeof( char ) == sizeof( BYTE ) , but sizeof( wchar_t ) != sizeof( BYTE ) ).
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Hello,
I am new to Win32API programming, Now is there a program that is available that will hook onto my program and basically tell me what messages are going into the message queue. It does not have to tell me all the messages but basic ones like WM_PAINT, WM_MOUSEMOVE, WM_LBUTTONDOWN, WM_LBUTTONUP, etc.
Thanks
|
|
|
|
|
It sounds like you want Spy++.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
My problem is that i have a timer that querys data via ethernet, once this data is returned, it populates some fields displayed on my dialog. BUT i want to have an if statement in there such that if the user is editing/has focus of a edit box, i dont want to overwrite what has been changed. At first look, i figured it would be easy, and just check to see if it has focus, but for some reason GetFocus() returns NULL... Any ideas on why its return this? Im using the standard MFC timing, e.g. SetTimer( UINT nID, UINT millisec, UINT Func_ptr/*i think, or something like that. I use NULL here*/ )
"There are 10 types of people, those who understand binary, and those who don't."
- Somebody, not me.
|
|
|
|
|
I'm not sure why you'd get NULL for GetFocus(). I thought a regular timer would be notified
on the same thread as the window proc but maybe not. The only thing I can think of is GetFocus()
is being called on a different thread than the window was created on.
An alternative would be to track focus on the associated edit controls by watching the
EN_SETFOCUS/EN_KILLFOCUS notification messages.
|
|
|
|
|
Wait, i had an epihany... I'm sorry, the reason it is 0, is cause it IS a different thread... I forgot that my timer just sends a message, and i have a constant listener which handles all messages... Which means of course it returns 0... Thanks for the initial thought, sorry for the bother
"There are 10 types of people, those who understand binary, and those who don't."
- Somebody, not me.
|
|
|
|
|
ok this might sound a little n00bish of me, but im desperate.
does anyone know how to create a .exe, that when loaded, launches 2 other exes.
and when the launching exe closes, the 2 exes it opened close too.
if any of you could provide me with some sample source or anything, i would be forever greatfull.
thank you.
|
|
|
|
|
homerjaylol wrote: does anyone know how to create a .exe, that when loaded, launches 2 other exes.
Such as calling CreateProcess() twice?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
this answers the first part of the question (starting other exes)
the second part intends to close the programs previously started (in step 1) if our program shuts down
|
|
|
|