|
Hello,
I am a little lost with some code. I have an MDI application without Doc/View Support
The code for File->New is the following (by default).
CMainFrame *pFrame = (CMainFrame*)AfxGetMainWnd() ;
// create a new MDI child window
pFrame->CreateNewChild(
RUNTIME_CLASS(CChildFrame), IDR_NICKMITYPE, m_hMDIMenu, m_hMDIAccel);
I want to open a bitmap and have it appear in this new window, yet it appears in the background of the project. How can I get the View to be set to this new window I made and not the background. For some reason, if I call pFrame->GetView() and then retrieve the buffer where my bitmap is, it puts it to the background. I really want to put in this new window, and am lost on how to do that. Can anyone give me any advice or point me to some articales or something that I could use to figure this out?
Thanks a whole bunch,
NickOne
|
|
|
|
|
Hi,
Does anyone have any idea how to create a line connecting two modeless dialogs, like in MSAccess relationship editor?
I could create the dialogs inside a CWnd or CView derived class and even the drag and drop support is enable between the two dialogs (which holds a CListBox control), but I couldn't figure out how to create (or draw) the line connecting them.
Any help or lights on these would be really nice.
Thanks,
Crercio O. Silva / DBTools Development
http://www.dbtools.com.br
|
|
|
|
|
I suppose you could pick an arbitrary set of points (say half the height of both dialogs) and then use the DrawLine method in GDI.
Nick Parker
May your glass be ever full.
May the roof over your head be always strong.
And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing
|
|
|
|
|
Nick Parker wrote:
I suppose you could pick an arbitrary set of points (say half the height of both dialogs) and then use the DrawLine method in GDI.
I couldn't find the DrawLine method. Is it the same as using LineTo, MoveTo?
Thanks,
Crercio O. Silva / DBTools Development
http://www.dbtools.com.br
|
|
|
|
|
Crercio O. Silva wrote:
I couldn't find the DrawLine method. Is it the same as using LineTo, MoveTo?
Sorry, I have had my head stuck in .NET lately as it is available in GDI+. You could write your own DrawLine function, here could be a prototype:
void DrawLine(CDC *dc, CPoint& start, CPoint& end);
Nick Parker
May your glass be ever full.
May the roof over your head be always strong.
And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing
|
|
|
|
|
I'm not familiar with the relationship editor,
but I would guess that the windows twixt which
the line is drawn are not top level windows
(modeless dialogs), but rather child windows
of some container and it is on the container
window that the line is drawn.
|
|
|
|
|
Scott H. Settlemier wrote:
I'm not familiar with the relationship editor,
but I would guess that the windows twixt which
the line is drawn are not top level windows
(modeless dialogs), but rather child windows
of some container and it is on the container
window that the line is drawn.
Oh, I guess I forgot to say this before. The dialogs are childs from a Dialog Container (A CWnd derived control).
Thanks for the tip.
[]s
Crercio O. Silva / DBTools Development
http://www.dbtools.com.br
|
|
|
|
|
CDC::MoveTo and CDC::LineTO ?
I think the problem you might have is how to handle the action itself, how to click ( somewhere ), then drag the mouse ( to draw the line ), and release ( to finalize the connection )
I'd do it by hand, and handle the WM_MOUSEMOVE, WM_LBUTTONDOWN and WM_LBUTTONUP of the modeless dialogs; on the WM_LBUTTONDOWN, "anchor" the starting point, and on the mouse move, draw the line from the anchor to the current point, and on the WM_LBUTTONUP, process the connection by fetching which dialog is the "target" and which is the source, and drawing the line from the closest border.
Max.
|
|
|
|
|
Maximilien wrote:
CDC::MoveTo and CDC::LineTO ?
I think the problem you might have is how to handle the action itself, how to click ( somewhere ), then drag the mouse ( to draw the line ), and release ( to finalize the connection )
This part actually is already done. I'm using a CListBox ctrl inside each modeless dialog. I managed to implement the drag and drop from one dialog to another. Although in the destination dialog there is a need to have at least one item selected (I couldn't figure out the item on the drop position). I'm now starting the code to draw the line itself. What I've done so far was:
- I derived a class from CWnd named CContainerWnd with these methods:
CContainer::AddDialog(CString pName)
CContainer::RemoveDialog(CString pName)
CContainer::CreateRelationship(CString PKName, CString FKName)
This class is the parent for all modeless dialogs. I have also used a CFormView as a container for doc/view arquiteture, which worked like a charm including the scrollbars.
Inside the CreateRelationship I managed to identify the dialogs position (which I save when created), so to draw the lines was quite easy. The problem comes when I move one of the dialogs. In this case it's necessary to clear the old line and redraw it in the new position. Also there is an even worse problem: if there is another dialog in between two that are related, the line will be drawn over this dialog, so far I couldn't figure out how to do it.
I think if I'm able to create a CWnd derived class just to handle the line it may solve my problem, but I'm not too familiar with that.
Thanks for the tips.
[]s
Crercio O. Silva / DBTools Development
http://www.dbtools.com.br
|
|
|
|
|
Crercio O. Silva wrote:
if there is another dialog in between two that are related, the line will be drawn over this dialog, so far I couldn't figure out how to do it.
You need to re-order the drawings. in your view, you need to draw the different lines then draw the dialogs.
Max.
|
|
|
|
|
Maximilien wrote:
You need to re-order the drawings. in your view, you need to draw the different lines then draw the dialogs.
I have implemented this. So far the lines are drawn as they should be. When the dialog moves a method in the CContainer erases the previous lines and redraw all of them again. I used this approach to handle the draw of the dialogs:
- first I connected WM_SIZE and WM_MOVE in the dialogs to the CContainer window, when one of them occurs it will call a method to repaint the lines
- in the paint lines method I first draw the lines and then I hide/show the dialogs in order to make the lines stay under the dialogs.
This is really working but the problem is I really think that using CDialog::ShowWindow() is causing me problems since the application goes into a infinite loop (looks like ShowWindow(SW_SHOW/SW_HIDE) updates the position of the dialog causing them to call the repaint method of the CContainer parent.
Las night I worked on this till 3:00AM I wasn't thinking clearly anymore. Maybe after some sleep ...
Thanks man
Crercio O. Silva / DBTools Development
http://www.dbtools.com.br
|
|
|
|
|
Hi,
I have a SDI application in which I create 2 extra threads. Using the debugger I get the following error intermittently:
Unhandled Exception at 0x77e6d756 in Application.exe: Microsoft C++ exception: _com_error @ 0x02a3f44
Then the file comip.h is opened and the following bit of code generates the afore-mentioned error:
HRESULT hr = CreateInstance( str, pOuter, dwClsContext );
The value of hr is 0x800401f0 CoInitialize has not been callled.
If anyone has any clue what is going on here, feel free to let me know.
I thank you for any suggestions.
Regards
Rui
|
|
|
|
|
If you access any COM objects or make any calls to COM functions you must first call CoInitialize() at the beginning of each thread.
Roger Stewart
"I Owe, I Owe, it's off to work I go..."
|
|
|
|
|
Thanks,
I forgot to add that I do have queries to a dB in my threads and yes I do have
CoInitialize( NULL );
at the beginning of the function called by the thread.
Unless the CoInit is at the wrong place.
I would also like to add that I am running my code in debug and the error does not always occur. It appears randomly and this is what is puzzling me.
Thanks
regards
Rui
|
|
|
|
|
I am using a CTreeCtrl and need to set up images for each Node in the CTreeCtrl .
i am doing the following
1. Setting up an ImagelIst as
CImageList images;<br />
images.Create(IDB_BITMAP1,10,5,1);<br />
m_tree.SetImageList(&images,TVSIL_NORMAL);
2. I insert this way :
HTREEITEM h_node=m_tree.InsertItem(ObjectName.c_str(),1,1,h_parent );
I find that the Image isnt getting displayed , although space is alloted for the size of the image !!
Please help
|
|
|
|
|
You've forgot to add
m_tree.SetItemImage(h_node,nImage,nSelectedImage);
Dmitry Timin
|
|
|
|
|
Hi,
I would like to create a code viewer which would take care of precompiler instructions (such as #define and #ifdef), that is, a viewer that shows only the code which is _really_ being compiled. Since i do not want to reinvent the wheel, do you know about a software already doing this ? Do you know about a place where i could find the sourcecode of a compiler (since i'll have to interprete the #if commands and so on) or anything that would help ?
Thanks a lot,
~RaGE();
|
|
|
|
|
In case this is for your own use as a MSDEV developer, then you should simply use MSDEV:
cl /EP sourcefile.cpp > output.tmp
(type "cl /?" on the command line for a list of options)
You may notice the output file (e.g. "output.tmp") contains long series of empty lines, owing to the fact that the MSDEV preprocessor doesn't strip those.
Again, use a free tool to join subsequent empty lines into one:
more /S output.tmp > output.lst
For example, I use the above tools to run the proprocessor through some XSLT source files that are part of a C++ project. In MSDEV, I create a custom build step like this:
cl /EP /DXSL /I$(ProjDir) /I$(ProjDir)\..\include $(InputPath) > $(IntDir)\$(InputName).xso
more /S /T4 $(IntDir)\$(InputName).xso > $(ProjDir)\tools\$(InputName).xsl
(takes input file, also specifies two include directories, creates intermediate *.xso file, merges multiple subsequent empty lines, replaces tabs with spaces (tabwidth 4), and leaves the result in tools\*.xsl.
Works fine for me.
Bernd
|
|
|
|
|
I'll give it a try. Thanks a lot.
~RaGE();
|
|
|
|
|
Hi all,
When I use 'custom' messages, how can I ensure that they are unique? Let's say I write a static library and I define some messages in there, in the range WM_USER + 100 up to WM_USER + 500. How can I ensure that they do not collide with messages in the same range in the program that will use my library? I know about RegisterWindowMessage, but according to MSDN that should only be used for ipc. Thanks in advance.
|
|
|
|
|
Never ever use WM_USER it was overused by some MFC controls so this
is no longer a save base value.
Instead use WM_APP as base for user defined messages.
Yours,
Alois Kraus
Siemens Medical Solutions
|
|
|
|
|
roel_v wrote:
I know about RegisterWindowMessage, but according to MSDN that should only be used for ipc
Huh? Where does it say that?
MSDN states that RWM are especially useful for inter process communiaction, but can be used anywhere.
In fact, I think they should.
But as an altertnative you have WM_APP+x.
For more info, please read the article about WM_USER. It has some clear guidelines when to use WM_USER, WM_APP and RWMs.
"My opinions may have changed, but not the fact that I am right."
Found in the sig of Herbert Kaminski
|
|
|
|
|
Huh? Where does it say that?
From ms-help://MS.MSDNQTR.2002JUL.1033/winui/winui/windowsuserinterface/windowing/messagesandmessagequeues/messagesandmessagequeuesreference/messagesandmessagequeuesfunctions/registerwindowmessage.htm
Only use RegisterWindowMessage when more than one application must process the same message. For sending private messages within a window class, an application can use any integer in the range WM_USER through 0x7FFF.
But I must say that not all of the documentation states it explicitly as here. Anyway, I'm off to read the WM_USER article now
|
|
|
|
|
You are right - it says explicitly 'only for inter application communication'.
But I can assure you that RWMs work even within an application
Maybe RegisterWindowMessage() has a large overhead or uses limited resources?
--
"My opinions may have changed, but not the fact that I am right."
Found in the sig of Herbert Kaminski
|
|
|
|
|
I thought that MSDN was basically outdated on this, and that there was no reason not to use RWM's. In fact, they are the only way to guarantee a unique id.
-Alex
|
|
|
|