|
Hi,,
I like to know how can I draw two perpendicular lines, from a specified point (CPoint).
the point (CPoint) is clicked by the user. and as soon as the user clicks, I want the lines to be draw.
|
|
|
|
|
---------------------CPoint---------------------- NOTE: the lines are ofcourse connected lines, not dashed
|
|
|
|
|
thanks for the help
Ehsan
Ehsan Behboudi
|
|
|
|
|
Something like this:
in OnLButtonDown
{
m_bDrawLine = true; // A flag telling us to draw a line
m_MousePos = point; // the position stored. Could also call GetCursoorPos/ScreenToClient in the OnPaint if you like
Invalidate(false); // Force a redraw, no erase
}
in OnPaint
{
CPaintDC dc(this); // device context for painting
if (m_bDrawLine)
{
m_bDrawLine = false;
dc.MoveTo(CPoint(m_MousePos.x, m_MousePos.y - 20);
dc.LineTo(CPoint(m_MousePos.x, m_MousePos.y + 20);
}
}
this will draw a 40 pixel high line either side of the point. Obviously, you'd want to pretty it up a lot, but you don't need to do any bounds checking - GDI will simply draw what it can and discard the rest. The problem you have though is that unless you build an array of points, etc., you will find they disappear when the window is redrawn, after a minimise for example, or being obscured by another window.
Christian
#include "std_disclaimer.h"
|
|
|
|
|
well, the subject says it all! i want to re-start my program (in a document/view MFC application) whenever the user selects a command from the menu. how do i do it? i need to access the pDoc pointer (which points to my data) from the MainFrm class. is it possible?
|
|
|
|
|
If you're in an MDI app, you can do this:
CMyDoc* pDoc = (CMyDoc*)MDIGetActive()->GetActiveView()->GetDocument();
Under SDI it's even easier:
CMyDoc* pDoc = (CMyDoc*)GetActiveView()->GetDocument();
Christian
#include "std_disclaimer.h"
|
|
|
|
|
i did this, and it worked. thanks.
CMyDoc *pDoc = (CMyDoc*) GetActiveDocument();
imran.
|
|
|
|
|
When I make a Dialog window (based on a resource) child of an MDI window, the caption bar appears inactive (grayed), however, my dialog is fully functional. Does anyone know how to make it look like an active window ?
David
|
|
|
|
|
Probably using the FormView class
|
|
|
|
|
Is there no way at all, besides the CFormview class ????????? I'm not that big of a fan of the Document/View architecture...
|
|
|
|
|
The D in MDI stands for Document, so you have chosen the Doc/View architecture, whether you decide to use it or not. The CFormView class *is* the way you can get an MDI application based on dialog templates. Otherwise you'd have to do something funky, like create a new, dialog based project and hold a vector of pointers to your child dialog boxes in it. I doubt this is viable, but it's not Doc/View.
Christian
#include "std_disclaimer.h"
|
|
|
|
|
Then could you tell me how to make it LOOK like a regular dialog... Without the minimize/maximize button and fixed size ?
|
|
|
|
|
The properties of the dialog template allow you to set if the border is resizing, and if there is a system menu/what is on it.
Christian
#include "std_disclaimer.h"
|
|
|
|
|
ohhh i'm in trouble! i have this small MFC application which shows a dialog box (modal one) and i just want the application to quit whenever the user presses the OK button on the dialog. how do i do it? i know onw thing: DoModal() returns an integer that tells me which button was pressed, so what do i do once i know it's an OK button? i've tried closeAllocuments but it doesn't help. it gives me some assert failure message. please help.
imran.
|
|
|
|
|
Post a WM_CLOSE message to your main window:
AfxGetMainWnd()->PostMessage(WM_CLOSE);
--Mike--
http://home.inreach.com/mdunn/
Tables, ladders, chairs, OH MY!
|
|
|
|
|
If you'd created a dialog based application, this should have happened for you automatically, but you can do it from anywhere with this:
PostQuitMessage(0);
Christian
#include "std_disclaimer.h"
|
|
|
|
|
i just knew mike and chris would be the first responders to my query. thanks guys, you've always saved my time!
imran.
|
|
|
|
|
I need to hide my picture(static-bitmap)that exist in my dialog resource
and to show it letter.
I successed to hide it with closeWindow() -> myPicture.CloseWindow();
But I dont success to show it with ShowWindow()
Who can help me ???
nili
|
|
|
|
|
ShowWindow( SW_HIDE ) and ShowWindow( SW_SHOW ) don't work???? I'm pretty sure you do not want to ujse CloseWindow, if you do, try useing OpenIcon to reverse it. I've never used that combination myself, but give it a whirl. If that doesn't work, you got me.
|
|
|
|
|
ShowWindow(SW_HIDE) >>> WORKS
ShowWindow(SW_SHOW) >>> DONT WORK !!!!!!!!!!!!!!!
What can I do to show the picture ????????????????
|
|
|
|
|
You've got serious problems somewhere - the only thing I can think is that it's (somehow) buried in the z-order, although I doubt it. HAve you tried the showwindow calls directly after one another, with just an AfxMessageBox in the middle, to verify that nothing else is effecting your ability to show the item ?
Personally, I do not bother with those picture show things, I just select the bitmap into a DC, lke this:
CDC picDC;
picDC.CreateCompatibleDC(NULL);
CBitmap pic;
pic.LoadBitmap(IDB_BITMAP);
CBitmap* pOld = picDC.LoadObject(&pic);
dc.BitBLt(x,y,width,height,&picDC,0,0,SRCCOPY);
dc.SelectObject(pOld);
dc.DeleteDC();
I have the DC creation/image loading stuff in a class, so in my case I just say
CGDC picDC(IDB_BITMAP);
dc.BitBLt(x,y,width,height,&picDC,0,0,SRCCOPY);
which is a lot neater, but in the end, I prefer to make drawing the bitmap conditional on a bool and do it in my OnPaint method. If you can't get ShowWindow working ( and you *should* be able to - you should post some code so we can check it out for you ), then that is your other option.
Christian
#include "std_disclaimer.h"
|
|
|
|
|
Are you performing ANY other operations on that control? If your doing the CloseWindow on it, take it out. Do ONLY ShowWindow. Also, I am assuming that there is not another control in the same location as the bitmap control in your dialog, or is there? If the bitmap is behind another control, and it is lower in the tab order, it will not show even with a SW_SHOW, you will need to SW_HIDE the other control. Aside from that, I don't have a clue.
|
|
|
|
|
My static control(bitmap) in my dialog box hidden for ShowWindow(SW_HIDE)
But it does not agree to show !!!
for ShowWindow(SW_SHOW) it show only empty(!) window(without the picture.)!!!
What Can I do ?????????
|
|
|
|
|
Did you consider taking my advice, instead of just re-stating your problem ? If you can see the frame, but not the image, have you tried reloading the image to see if it's getting lost ?
Christian
#include "std_disclaimer.h"
|
|
|
|
|
If the control itself displays but the bitmap does not than Christian is right - you've got something funky in the display logic for the bitmap.
|
|
|
|
|
In CDocument::Serialize I access a .ini-file. All is ready now.
But I want to protect the file currently in use from being edited/deteted/moved... with another application.
How can I lock the file (like in Word: "The file you want to access is currently in use" (or similar)
Can anybody help me?
:-|
Friedrich
|
|
|
|
|
Hello, the codegurus around the world.;)
When we open Word file, another temporary file is created.
So, if someone first opens the file and another temporary file is created,
the other people don't have the previlege to save this file.
Does this work?
Or, move this file to the temporary directory which anyone may not find this file easily?
Have a nice day!
-Masaaki Onishi-
|
|
|
|