|
thanks, the BringWindowToTop() works well.
I add m_fButton.SetFocus()after m_fButton.Create(...);
It's still useless,
In the same way, I add a CFEdit derived from CEdit class,the first click or enter char are ok.
|
|
|
|
|
yes,you are right, the first click miss is due to set the focus of flexgrid.
the first mouse click in the flexgrid area,no matter which sub control is clicked, the focus is set to the sub control or flexgrid.
so,I want to add the set focus code in CBTGrid class function flexgrid OnMouseMove, while mouse move over flexgrid,set the focus right away;
void CBTGrid::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CMSFlexGrid::OnMouseMove(nFlags, point);
CBTGrid::OnSetFocus(CWnd* pOldWnd);
}
now,the problem is how can I get the CWnd* pOldWnd?
or there is another good idea?
I'm appreciated your suggestion
|
|
|
|
|
Don't call OnSetFocus (the functions starting with 'On' are called automatically, you won't call them directly). Instead use SetFocus.
Cédric Moonen
Software developper
Charting control
|
|
|
|
|
wow, your Charting control is a excellent tutorial for me!
yes, SetFocus is ok now.
but every mousemove will spring the code; I wanna know is there any method for judging that the focus have been set to the flexgrid or the sub controls?
if not set yet, then set the focus, or not set.
void CBTGrid::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CMSFlexGrid::OnMouseMove(nFlags, point);
if (...focus is not on flexgrid or it's sub controls....){ SetFocus();
}
}
|
|
|
|
|
I don't think this will make a big difference.
Anyway, why don't you use BringWindowToTop ? It's much more cleaner than making a kind of hybrid control .
Also, there is a lot of informations in the MSDN, try to use it because it is very helpfull.
zeus_master wrote: wow, your Charting control is a excellent tutorial for me!
Thanks
Cédric Moonen
Software developper
Charting control
|
|
|
|
|
Cedric Moonen wrote: I don't think this will make a big difference.
Anyway, why don't you use BringWindowToTop ?
as you know,I need create many buttons(more than 200) for the flexgrid, and some other controls in the cell, BringWindowToTop function must reset after flexgrid create/change/resize.....the code become more difficult for management.
Cedric Moonen wrote: Also, there is a lot of informations in the MSDN, try to use it because it is very helpfull.
yes,but it is very difficult to find
|
|
|
|
|
sorry for disturbing you so many times.
I found I'm real a fool.
Only a simple way is add the WM_MOUSEMOVE message for CFButton class, then add SetFocus();
whether or no, thank you very much.
|
|
|
|
|
Hello everyone!My first post so i\m kinda nervous
What's my problem:just started visual c++ and i'm trying hard to make a child window for my app(a single document made with app wizard ). I have some stuff happening in the main window and i want to be able to pop up a new window showing the status of some parameters from the main window and also to be able to control them from that second window. I would really appreciate a link or something to help me with this
|
|
|
|
|
v3r50r wrote: My first post
Wellcome
Open a new window could be a big problem if you have to initialize it, but if you want to understand how create a standard new window (in an MDI app) follow the sample code used in
CMDIFrameWnd::OnWindowNew() in winMDI.cpp
that create a copy of the current window.
void CMDIFrameWnd::OnWindowNew()<br />
{<br />
CMDIChildWnd* pActiveChild = MDIGetActive();<br />
CDocument* pDocument;<br />
if (pActiveChild == NULL ||<br />
(pDocument = pActiveChild->GetActiveDocument()) == NULL)<br />
{<br />
TRACE(traceAppMsg, 0, "Warning: No active document for WindowNew command.\n");<br />
AfxMessageBox(AFX_IDP_COMMAND_FAILURE);<br />
return;
}<br />
<br />
CDocTemplate* pTemplate = pDocument->GetDocTemplate();<br />
ASSERT_VALID(pTemplate);<br />
CFrameWnd* pFrame = pTemplate->CreateNewFrame(pDocument, pActiveChild);<br />
if (pFrame == NULL)<br />
{<br />
TRACE(traceAppMsg, 0, "Warning: failed to create new frame.\n");<br />
return;
}<br />
<br />
pTemplate->InitialUpdateFrame(pFrame, pDocument);<br />
}
|
|
|
|
|
well..it's like this:all i want to do is to press a control(button) on my app a dialog to appear saying:parameter1 is:...(from first form ).thank tou and i'll look the MDI up ( i suppose that's multi document something right? )
|
|
|
|
|
v3r50r wrote: all i want to do is to press a control(button) on my app a dialog to appear saying:parameter1 is
Then you should create a dialog template (through the resource editor), then create the associated class. Then, on the button function handler, create an instance of this class and call DoModal.
If you want to pass some parameters, then add a new function in the class (that receives the data) and use these parameters in OnInitdialog. This new function is called before you call DoModal.
|
|
|
|
|
ok i thonk i got it thank you
btw,what does DoModal() do?
and how do i
Cedric Moonen wrote: add a new function in the class (that receives the data)
receive the data? I mean, if say i have in the main frame's class an int data;
and then it's initializrd in the application by say data=10; how do i write the function on the new dialog that gives me data's value?
|
|
|
|
|
You only need to show some parameters value in a string for example ? Then it is much easier to go for a simple MessageBox.
Here is how you can do that (let's say that you want to show the values of Param1 and Param2 wich are both integers):
char szString[255];
sprintf(szString,"Value of Param1: %i, Value of Param2: %i",Param1,Param2);
MessageBox(szString);
(I suppose you put this code in a class derived from CWnd).
Take a look at the doc of sprintf[^] for more details.
|
|
|
|
|
mmm
then you need this:
<br />
CString String;<br />
int N=5;<br />
String.Format("parameter1 is: %d", N);<br />
AfxMessageBox(String);<br />
|
|
|
|
|
wouldn't that print out : parameter 1 is=5 ?
i need the real value of param 1
|
|
|
|
|
|
Do we have any SDK to get the charset for the current language OS?
I have an application which will dyanmically generate the html file and display. I have a requirement where if I am displaying the html in the Japanese OS, I should mention japanese charset in the content info of HTML file.
Thanks in advance.
Sandeep
|
|
|
|
|
My application is reading data from serial port. But the data may arrive at any random time. So i want to interrupt the application when data arrives on the serial port. Can anybody suggest me some solution to this problem.
aasstt
|
|
|
|
|
You won't be able to use hardware interruptions in your program (and it's bad design also ). A better solution is in general to spawn a thread that will poll the serial port for data. A good design for doing that is starting this thread in a separate class that will send a message to your application when data is available (custom message). This may sound 'complicated' but if you don't want to freeze your GUI, it is the best way of doing that.
|
|
|
|
|
Cedric Moonen wrote: to spawn a thread that will poll the serial port for data.
From my experience in the past, polling eats processor resource even though we have added something in the loop in the thread like Sleep(1) .
Personally I prefer to feed an event to the serial port API, and use WaitForMultipleObjects or WaitForSingleObject ...
Cedric Moonen wrote: This may sound 'complicated' but if you don't want to freeze your GUI, it is the best way of doing that.
Yes this is so true! Basically all those communication related applications have to be designed in multi-threading to prevent from GUI frozen.
Maxwell Chen
|
|
|
|
|
Use Overlapped I/O and WaitForSingleObject
|
|
|
|
|
http://www.codeproject.com/system/simpleserialcomm.asp
http://www.codeproject.com/system/cserialport.asp
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Is pTmpl initialized? In your example there isn't any init.
if yes what about pTmpl->UpdateAllViews(NULL); ?;)
|
|
|
|
|
Now again question is hide
|
|
|
|
|
I hope that the author isn't desappeared like the message (and that my resp solved his problem;))
|
|
|
|