|
Ok
thankx I dont really know GDI that well
However what if I send a message and send EM_SETRECT to the edit
control then get dc of the contol "edit multiline thats is"
selct the font and color I want into the the DC and do a DrawText
is the rectangle parm of the DrawText a rectangle within the DC of
the Edit multiline ???
|
|
|
|
|
Sorry
For the earlier post if I use EM_POSFROMCHAR
To get the X,Y cords of the where I want to highlite the text
then TextOut with those x,y cords
My questions then becommes does anyone have an example
EM_POSFROMCHAR as the documentation on MSDN is not clear
|
|
|
|
|
I am currently writing a Windows application using MFC and C++. My main window has numerous objects of type CEdit and CComboBox used to create input fields. In addition, depending on the user’s data, additional fields may be created by the program.
I would like to implement the program such that hitting the tab character in one field advances to the next field and hitting shift tab takes you to the previous field. Is there any easy way to do this?
I am thinking that the best way to do this is have a linked list of pointers to the fields in main window. However, it seems like a fair amount of work. Is there an easier and/or better way to do this?
Thanks
Bob
|
|
|
|
|
I thought that the tab/shift tab just worked, based on the ids of the controls, that is, in numerical order. Have you tried this ? I am certain there is a tab order property or that the general Id of the control is used, to make this just work.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Actually, as far as i know, the controls come after each other in their Z-Order (which is, by default, their creation-order), their IDs have nothing to do with the TAB order. And it should work by default indeed. But to get your "dynamically created" controls to gain focus when using TAB you need to give the WS_TABSTOP style to them. You can also change the Z-Order and thus the tab-order by using SetWindowPos(Previous_control_handle, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOZORDER); I think there also was some message sent to the dialog to obtain the next or previous control when tabbing, am not sure of that.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Thanks for the response. I added the paramter WS_TABSTOP to my call to CreateEx. However,
hitting the tab key did not move me to the next input field. Below is the code that I used to
create the two fields:
int retValue =
spendingArray[0].CreateEx( WS_EX_CLIENTEDGE, TEXT("edit"), NULL,
WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP | ES_AUTOHSCROLL,
50, 50+charHeight+6, 10*charWidth, charHeight+6,
m_hWnd, (HMENU)500, NULL );
ageData.CreateEx( WS_EX_CLIENTEDGE, TEXT("edit"), NULL,
WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP | ES_AUTOHSCROLL,
300, 50+charHeight+6, 10*charWidth, charHeight+6,
m_hWnd, (HMENU)500, NULL );
While the fields appear to be created correctly, hitting tab in one of them does not move me to
the other. I am wondering what I am doing wrong? Any ideas?
I am thinking that I should try writing a small application to see if that works. What do you think of this idea?
Thanks
Bob
|
|
|
|
|
Are those new controls placed on somekind of a panel derived from CWnd or maybe on a dialog which is a child control of another window? If so, make the panel or child dialog have the WS_CONTROLPARENT style set. If that's not that it, you could try to make that test project to see if it works there but i thinnk it should. Could it also be that some control(s) on your GUI "swalow" the TAB hits?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
The parent of these child windows is an instance of a class dervied from CFrameWnd. Also, I could not find WS_CONTROLPARENT in the documentation. Are you sure about that term?
Bob
|
|
|
|
|
Ah, sorry, i got a bit mixed up there, the "control parent" thing is a setting in Dialog editor (in VS's resource editor) you use when you make a dialog resource be a child of another dialog. Sorry. But it might be related since it's for including the child dialog's controls in the tab order of the parent.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Thanks for the response. It is now working the way I want it to. Part of the problem was that I needed the following routine:
BOOL
CMainWindow::PreTranslateMessage( MSG *pMsg )
{
return ::IsDialogMessage( m_hWnd, pMsg );
}
However, I do not understand why. Maybe you could tell me.
Bob
|
|
|
|
|
I have two other follow up questions:
1) I would like the program to behave in such a way that when the user hit's return
the program move to the next field. Just the way tab works. Is there a way to do this?
2) When the user moves to the next field, say by entering a tab character, I would like
to know that and be able to check his input so far. Is there a way to do this?
I ran the debugger and noticed that my input field is not seeing the carriage character any more. I am thinking that character (message) is being processed in the following routine:
<br />
BOOL<br />
CMainWindow::PreTranslateMessage( MSG *pMsg )<br />
{<br />
return ::IsDialogMessage( m_hWnd, pMsg );<br />
}<br />
Do you agree with my reasoning?
Thanks
Bob
|
|
|
|
|
How about catching the enter keyhit and changing it to a TAB hit or maybe posting a tab hit? For example in that PreTranslateMessage you made you could try something like:
BOOL CMainWindow::PreTranslateMessage( MSG *pMsg )
{
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN) pMsg->wParam = VK_TAB;
return ::IsDialogMessage( m_hWnd, pMsg );
}
or maybe
BOOL CMainWindow::PreTranslateMessage( MSG *pMsg )
{
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN)
{
PostMessage(WM_KEYDOWN, VK_TAB, 0);
return TRUE;
} else return ::IsDialogMessage( m_hWnd, pMsg );
}
You probably need to experiment with that some, maybe you need WM_CHAR instead of WM_KEYDOWN and maybe you need also WM_KEYUP for the WM_KEYDOWN. For your second point, you can use the WM_KILLFOCUS message or notifications from the controls sent upon loosing the focus (like EN_KILLFOCUS for edits), but i don't much recommend doing that, validating on kill focus can lead to nasty results, there are articles out there about it though, try googling for them.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Thanks for the response. Your suggestion of using the following statement:
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN) pMsg->wParam = VK_TAB;<br />
worked. I did some googling and I found that you are right. I do not want to check it when I lose
the focus but what about when the user hits the tab key. I think I want to check it then. The problem is that my routine for processing user inputs is not seeing the tab key. So, how do I know when the user has hit tab to leave the field? I suppose I could put the code in the parent window, but that seems very kludge to me. I suspect you know a better way. What is that better way?
Bob
|
|
|
|
|
Also in that PreTranspateMessage you could catch the TAB hit as you did with the enter key and perform validation and if you want the user to stay in a control that doesn't have a valid information written to it you simply don't relay the message to that IsDialogMessage call. But you don't want validation if the user clicks away from your controls (so changes the focused control via the mouse and not by hitting the TAB key)?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Thanks for the response. I now have it working the way I want it. Your help has been most valuable.
Bob
|
|
|
|
|
I'm glad i could help. Good luck with the project...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
I have downloaded the coderoject demo code form Url:"http://www.codeproject.com/KB/IP/IOlkAccountManager.aspx"
Now we want to modify
IOlkAccount properties, ie PROP_ACCT_ID,
PROP_ACCT_IS_EXCH, PROP_ACCT_NAME, PROP_ACCT_SEND_STAMP, PROP_ACCT_STAMP and
PROP_ACCT_USER_DISPLAY_NAME.
How can we do it?
i hope experts can solve this problem..
|
|
|
|
|
Hi,
I need to develop an GUI interface for my project. Where in my embedded device(Ambiance analyzing robot, have on-board micro-controller) can be connected to PC via COM port.
As of now I have a set of commands developed to communicate with micro-controller, and I use Hyper-terminal to send the commands to the micro-controller via COM port, and receive back the outputs on Hyper-terminal in HEX format.
I want to develop a user interface where user can set the parameters and click a button to generate the command and send it to COM port, and on receiving data back from COM port displays it on separate section of the screen store it in a file.
I have Visual Studio Team Suite 2008, 1 year evaluation version and it got all kind of tools in it, Visual basic, Visual C++, MFC, WPF, WinForm, Win32, and I am confused what to do, which is the right tool to deliver fast and with at least the basic features.
I have very minimal experience of building GUI in Visual Studio 6 Visual C++ using MFC in past (precisely 4yrs back, one application), i don't know visual basics, have little knowledge of C#. I do not want my application to be behind in technologies, and wnat to develop in latest technologies.
Can you help me find the best combination to do this development, like Visual C++ with MFC, Visual Basic, Visual C++ with Win 32, or CLR Windows forms application etc.
Thanks for all your help and patients.
Karmendra Suthar
|
|
|
|
|
Karmendra,
If you want to use the latest technologies then I would use C# and .NET. If you go that route, expect a long learning curve. I am personally partial to C++ with MFC.
Bob
|
|
|
|
|
Bob,
Thanks for your reply, I even talked with some friends of mine they said Windows Form Application using C# would be easy to learn and implement. What in your opinion would be any pros or cons of using this combination?
Regards,
Karmendra
|
|
|
|
|
Karmenda,
I do not know Window Form Applications well enough to give you a meaningfully answer about how hard or easy it is to use. My feeling is that learning C# and .Net at the same time is going to be a lot of work. At least, it would be a lot of work for me. However, it is the latest technology and therefore it could be the right solution for you. By the way, using .NET and C++ is kind of a kludge and I would not recommend it.
I am wondering, what is your estimate of the time for you to do this project. I think the more time you have the better off you are by learning the C# and the Windows Form Application.
Bob
|
|
|
|
|
I want to be notified whenever the user presses "Paste" or "Copy" menu items from within any menu in the whole system. can any one help me please?
Thank you masters!
|
|
|
|
|
Why the menu items? Many users might use Ctrl+C / Ctrl+V instead.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Those aren't system-wide events. They are implemented individually
per application.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hai all,
In pretranslate message i have given the code to move from one dialog box to another, using two key F2 and F6 we can shift between two keys. and when calling the dialog box everytime a domodal() is called and the corresponding window is Updated.
In the dialog box, Which appears when F6 is called a number of other dialog boxes appear on the click of each and every button. When we move between these dialog boxes it gets closed or the window application disappears after sometime. Please some one help me.
Thanks and regards
Bhanu
|
|
|
|
|