|
thks for your previous reply about creating multiple instances ..it's exactly what i was looking for!...(and i find your english very clear actually)
as for the code, below are just some of the codes.i don't know if it's sufficient for you to find out what's going on.Actually if you don't mind emailing me your email address, i cant send you a more complete source code.
in my CView class..
dlgGraph[i]=new CGrapDlg(this);
dlgGraph[i]->SetLink(i);
if (dlgGraph[i]->GetSafeHwnd()==0){
dlgGraph[i]->Create();
}
dlgGraph[i]->ModifyStyle(0,WS_VISIBLE);
in my CGrapDlg...
CGrapDlg::CGrapDlg(CView *pView)
:CDialog()
{
m_pView=pView;
}
BOOL CGrapDlg::Create()
{
return CDialog::Create(CGrapDlg::IDD);
}
void CGrapDlg::OnPaint()
{
CWnd* graphFrame = (CWnd*)GetDlgItem(IDC_GRAPH_FRAME);
CDC* pDC = graphFrame->GetDC();
try{
plotGraph.Plot(pDC,link);}
catch(...)
{
AfxMessageBox("Error plotting graph.Has files been opened?");
}
ReleaseDC(pDC);
}
Thanks alot, really.
|
|
|
|
|
1.
I don't know if this is the problem or not... but it seems that you've derived the CGrapDlg class from a CView not from a CDialog...
2.
this is not a problem, only a typo that makes things clearer: if you derive from a dialog write xxxdlg and if you derive from a window write xxxwnd (only if you want of course).
3. I don't understand the use of the "link" var: if you have declared plotGraph inside (as a member of) the CGrapDlg class you don't need that, because PlotGraph it's unique and property of the actual instance of CGrapDlg. (Be sure not ot miss the fact that the handle (if that is what Plot(DC,Handle)) needs is not a numeric ID that can be assigned...
Each window has its own handle that can be obtained using GetWndHandle() (memory obtained (don't trust a lot the last part)).
Hope this helps.
|
|
|
|
|
1.
No, i derived CGrapDlg from CDialog,not CView, but i passed a CView parameter into its constructor because a tutorial i was following did that and because i was creating CGrapDlg from my CView class.
3.
yes, plotGraph is a member of CGrapDlg and "link" is just a variable needed for my program to know where to retrieve data for my drawing purposes, it's not a handle.
is there any problem with the way i'm creating the modeless dialog?
thks thks
|
|
|
|
|
AArgh!
sorry!
I didn't see the ": CDialog" !!!! (how do I hate this sort of things...)
There isn't any problem in your dialog creation...
Place a breakpoint, a TRACE or something else at the beggining of the function (OnPaint) in order to know if it is being called or not.
Once you'll know if the f(x) is being called or not, if the function is being called, try to know if the DC that you are getting is the right one drawing something easy to it...
If the function is not called try to place its content in the OnErasebackground handler (I don't remember where, but I have read that the right place to process the drawing messages in the dialogs is that function).
hope this helps...
|
|
|
|
|
thks for your reply.
as u suggested, i try debugging and found out that OnPaint() was called and entered.Below, is relevant code snippet in OnPaint().It was found though, that "plotGraph.Plot(pDC,link)" was not executed.plotGraph is a CObject-derived class and Plot(CDC *pDC,int link) is the function definition...link var is just for my own program purpose.
CWnd* graphFrame = (CWnd*)GetDlgItem(IDC_GRAPH_FRAME);
CDC* pDC = graphFrame->GetDC();
plotGraph.Plot(pDC,link);
The odd thing is this had worked fine while i was using modal dialog boxes.
any idea what is or might be wrong?
a big thank you.
|
|
|
|
|
Seeing this I can only tell you:
NOTE:
surely the things that I'll tell you will be very obvious for you, but let's give it a try, who knows...
1.
check if you are getting the right pointer to graphFrame.
2.
Once you will be sure that the right pointer is obtained, then you should check if the pDC variable is getting the desired value.
3.
After all this... you should check if the link var points to where it should(or have the value it should)...
4.
the most fool thing to check...
sometimes the compiler gets mad and only a deletion of some files and a full rebuild gets it to work...
but before doing so...
raner wrote:
"plotGraph.Plot(pDC,link)" was not executed
please, place a do_nothing little bit of code like the next one before and after that line in order to see if the execution gets broken before or during that line call.
if (true)
{
plotGraph.Plot(pDC,link);
} Using that piece of code you'll be able to see if you enter inside the if clause or not... and you'll be able to see if the error comes before that call or not...
5.
if you have the font code of the plotGraph class, try to debug the Plot function in order to know what is happening,
hope this helps...
|
|
|
|
|
i noted down your suggestions and will try them to debug my pgm..in the meantime..u have any idea where to set the message map for OnEraseBackground?...because i cant find it in the Class Wizard.
really grateful for your help
|
|
|
|
|
You should right-click your dialog class in the class wizard, and then, select "Add Windows Message Handler", once this has been done, in the "Filter for messages available to class" combobox (right bottom of the dialog), select "WINDOW".
Now, you have only to select "WM_ERASEBKGND" from the "New Windows messages/events" listbox (left top of the dialog), after that you have to press the Add and Edit button.
Hope this helps...
|
|
|
|
|
u cant do so..because the focus will be on first dialog and until u dismiss that it will not let go the control onto the next line..for using multiple dialogs at asme time..use property sheets..and that will appear as tabs of anything u see..like internet opetions..I hope you can go on with it....
cheers
Himanshu
|
|
|
|
|
Can anbody point me to a good article or resource for CListView and Owner or Custom Draw? What I am trying to do is capture the point were the list view draws its "highlighted" section so I can redraw it my way.. I don't want to fill the background.. just draw a colored border around the item.. I figured there would be a event for these seeings how the control has a GetItemRect() function and I don't really see any other purpose you would need the Items Rect.
C# a poor attempt at bringing C++ to the VB masses
|
|
|
|
|
There are very good articles here in CP. Just look in the Controls section.
|
|
|
|
|
Hi everyone
For the application I am working on I need to find out the duration of internet connection. Duration of internet connection will include the actual amount of time the user is browsing i.e. if the user connects to the internet and stays idel then connection time will be zero
How can I find out such duration? Is there any API for this?
I need help urgently.
Thanks
Ashish
|
|
|
|
|
Hi,
i am currently using overlapped IO mode WriteFile() to control serial port. i met problem! i don't know when the output data are completely sent from the output buffer. that's essential for me as i need to toggle DTR pin after data completely transmitted.
i tried GetOverlappedResult() after WriteFile(). however, even it report to me that lpNumberOfBytesTransferred same as my data size. the data still in the buffer, it is not completely sent. (i obtained this information thro' a CRO monitoring the pins)
so, could anyone give me a help? i think it is the same case for File IO. so, pls give me any help!
thanks!
jim
|
|
|
|
|
Hey!
lemme into myself.
i am Arun from India.
I have got this problem, if anyone can help me then i'd be glad and very thankful.
In a Single Document Interface Application,I have a HTML bar on top where i've got a simle page with links on it. And in the client area there are list controls and others. There are two toolbars, one on the top (below the HTML bar) and the other on the lefthand side.
Now, here is the problem... when i click on the links on the HTML bar, the two toolbars get DISABLED. To get them back enabled, i have to click on the client area again... i.e. on one of the list controls.
wud anybody tell me how i can avoid the toolbars from getting disbaled?!!
thank you.
|
|
|
|
|
Hello there!
I used to use the CHtmlView class extensively a few years ago. I remember a time when I had a splitter window configuration with a CHtmlView on one side and a CFormView on the other side of the splitter. Certain toolbars would mysteriously get disabled when I made selections on one side. I believe I solved the problem by calling CFrameWnd::SetActiveView(...) fn whenever I handled an event from the other side of the splitter. It had the same effect as the user clicking on the client area.
Art
|
|
|
|
|
Hi Art,
I am trying out the solution that you suggested...
But what r the parameters that i pass into the function and where do u think it is appropriate that i must call this function at?
I cud think of OnKillFocus() of CMainFrameWnd as one option.
Now the function is of the following type..
void SetActiveView( CView* pViewNew, BOOL bNotify = TRUE )
what am i to send as the fist argument? The client view is a runtime class called CMyView, so... how will i do it? please help.
|
|
|
|
|
arunbooboo,
After looking at some of my old code (before I became grey haired) I realize I was working with CSplitterWnd class. When the user clicked on a button on the left pane it would deactivate certain menu options/toolbars that were unique to the right pane (CHtmlView based). So what I did was call CSplitterWnd::SetActivePane(..) setting the right pane as active to take care of the problem.
Your problem has a slightly different twist. You've apparently got this "HtmlBar" that is taking focus when you click on it. The toolbars are disabled probably because they are tied to the view. What class handles the events that are picked up by the selections in this "HtmlBar". If you are in the view class you might try calling CView::SetActiveWindow() at the end of each handler.
Art
|
|
|
|
|
Hey Art,
Thank you for writing back.
I made some progress regarding the problem but all is not well!!
The HTML bar that i was referring to is derived from CHtmlView class.
Okay, so when i click on it the focus is set on this. Now all i need to do is reset the focus back on to the main view. unfortunately the pOldWnd parameter that is passed into the OnSetFocus function of my CHtmlBar class is that of either CMainFrame or CListCtrl or CMyView (THE VIEW). I can only use SetActiveView() function if it pOldView is referring to CMyView, else it gives me an error at IsChild() which is called in SetActiveView() of CFrameWnd class.
Now i think i need to use SendMessage(WM_KILLFOCUS, , ) from OnSetFocus() function of CHtmlBar. But I need to fool the application in beleiving that this message is from CMyView.. how do i do that? HELP PLEASE ?!!
Wud u tell me how the remaining two parameters of SendMessage can be used to send this kind of a message.
Okay! hope i am not bugging you.
I'd/I am really appreciate/appreciating the help you are giving me.
Luv Arun.
|
|
|
|
|
Try using (WM_KILLFOCUS, 0, 0) and see what happens. I really can't help any more since I can't see your program.
Art
|
|
|
|
|
please give me some ideal about how to develop a software just like ACDsee ,that don't need power function, thank you !!
|
|
|
|
|
There are several apps on CP that use GDI+ to do exactly that, and the FAQ explains how to load multiple image formats without GDI+ if you don't want to use it.
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
|
|
|
|
|
Where the default toolbar images comes from in SDI/MDI applications?
I mean, what is the dll name that holds that images in its resource?
|
|
|
|
|
They're usually compiled into the executable as BITMAP resources.
If you open the file "as resources" in the IDE you should be able to see them.
Anna
www.annasplace.me.uk
"Be yourself - not what others think you should be" - Marcia Graesch
Trouble with resource IDs? Try the Resource ID Organiser Add-In for Visual C++
|
|
|
|
|
I know that. However, the images are copied from somewhere else.
Someone in codeguru site told me that i can find them in the graphic folder
under in Visual Studio folder.
I am looking for print-preview icon like in MS office.
|
|
|
|
|
I believe they are stored in User32.dll .. A MSJ article by Paul eons ago demonstrated writing an application to extract RIFF file types from resources.. I believe the same article explains that opening a resources (in this case.. I believe User32.dll) as a "resource" in the IDE you can broswe the icons and bitmaps.. they should be stored as bitmaps in there.. or you could just use app wizard to create a SDI project and browse over to your res directory and open toolbar.bmp .. should have the basic ones in there.
C# a poor attempt at bringing C++ to the VB masses
|
|
|
|