|
Hi all,
I have web browser object in my dialog, and i run flash advertisement in it.
problem is some of the flash advertisement steal the focus from my dialog, so if i am typing inside an edit box and advertisement is changed, focus is being steal from my edit to the internet explorer server object.....
is there a way to prevent it?
thanks
Yaron
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
You could try handling the WM_KILLFOCUS message and reset the focus back to your edit control if the browser object was the one that grabbed the focus from the edit control.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
thank you for your reply...
i tried what you said but the problem is that clicking on the advertisemnt should launch a web page
but if i click the advertisement and the kill focus from the edit is called, the focus is set back to the edit and the web page is never launched...
how can i bypass that?
thanks again
Yaron
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
You should be able to check if the user switched the focus (via the keyboard or mouse) or if the ad window grabbed the focus.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
thanks for the help....
how do i during OnKillFocus obtain mouse or keyboard click?
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
Let's say we have:
some functions f1, f2, ..., fn (like sin, cos, tan etc.)
a number like 5 (or a variable like x).
and the array char* a[] = { 'f1', '(', 'f2', '(', ..., '(', 'fn', '(', '5', ')', ')', ..., ')', ')' } .
I want to calculate the f1(f2(...(fn(5))...)) .
I know how to do this with RPN and stacks (even using arrays of pointers to functions), but I'm looking for the fastest way (and I believe this is using arrays of pointers to functions and WITHOUT using RPN and stacks)
(I have the ability to include brackets [] where needed in the array)
modified on Sunday, November 30, 2008 7:10 AM
|
|
|
|
|
C++ can't do that. If you want to solve a function, you need to write it in the source code and compile it like any other part of a program.
|
|
|
|
|
Hi,
would any one have any tips re: Setting the font and Color of a Multiline edit control well to be more specfic
is it possible while processing the WM_CTLCOLOREDIT in a Multiline edit control
to set the font and or color of a line or selected text in a Multiline edit control
|
|
|
|
|
Not as far as I know. I use a rich edit control if I want to do that.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
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. <
|
|
|
|