|
Hi all
i'm about to begin developing an application that requires me to draw an image on a either a form or a dialog box (if possible?). Basically the image will consist of a series of lines and basic shapes interconnected. What i would then like to be able to do is with the mouse click on individual lines and in doing so automatically change their properties e.g. say i clicked on a line it would change from green to red. Is this sort of functionality achievable. The issue i'd have from a conceptual point of view is how do you determine which line you have clicked on, if any, in the mouse button event handler???
If possible i'd like to be able to implement this in VC++ as i have very little VB experience. so to go back to my earlier question is it possible to draw lines shapes etc. on a dialog box? i've never tried anything like that before and unfortunately for this particular project the SDI or MDI app look would not be suitable!
Any advice is appreciated!!
Regards,
Griff
|
|
|
|
|
Paul Griffin wrote:
is it possible to draw lines shapes etc. on a dialog box?
of course. do it in the OnPaint function.
Paul Griffin wrote:
do you determine which line you have clicked on, if any, in the mouse button event handler???
in your OnLButtonDown handler, you'll need to run through your list of line/shape objects and determine which, if any, of these objects contain the point-of-click. if there are multiple objects, you'll have to figure out a scheme for picking just one (Z-order).
-c
When history comes, it always takes you by surprise.
|
|
|
|
|
Hey Chris
thanks for the quick reply ... sorry if that question about drawing on dialog boxes seemed stupid ... but i have very little MFC experience and even less with drawing with MFCs
I think i get what your saying though take the co-ordinates returned from the OnLButtonDown handler and match them against co-ordinates in the list of shapes .. seems blatantly obvious when someone points it out to you.
thanks again!!
Griff
|
|
|
|
|
Take a look at DrawCli MFC Sample.
|
|
|
|
|
I want the cdialog to come up square in the middle of my app. So I did the foll, but its really not at the center at all!!!!
CRect cRect;
GetClientRect(&cRect);
int width = 150;
int height = 50;
CPoint cPoint;
cPoint.x = cRect.Width()/2 - width/2;
cPoint.y = cRect.Height()/2 - height/2;
ClientToScreen(&cPoint);
msgText.Format("Number of files found %d",m_nToDisplay);
CMsg* pMsg = new CMsg;
if (pMsg == NULL) return;
pMsg->m_msgText = msgText;
BOOL ret = pMsg->Create(IDD_DIALOGMSG, this);
if(!ret) return;
pMsg->ShowWindow(SW_SHOW);
pMsg->MoveWindow(cPoint.x, cPoint.y, width, height);
Appreciate your help,
ns
|
|
|
|
|
MoveWindow works relatively in the client area of a parent window. You shouldn't use the ScreenToClient call.
Pavel
Sonork 100.15206
|
|
|
|
|
tried that, and it positioned it at the corner top of my screen when for testing purposes I told it move 0,0...no screentoclient etc...not at the corner of my app..
Appreciate your help,
ns
|
|
|
|
|
Have you tried just doing CDialog::CenterWindow() ? You can pass the parent with which you wish to work to determine the center.
|
|
|
|
|
I did CenterWindow(0) and its at the center of the screen, not my app. I tried passing in (this) in my parent view, so then it does stay along with the client but it doesnt center it ...ths might be a problem related to the fact that I fitted my view to be the size of the frame using CPs CenterWindow article by Brian HArt. SO maybe its centering it to what would have been had I not meddled with the sizing...
Another thing: the dlg style is popup, not child, but I dont know if thats relevant. I need it to be popup. For the moment popping it up at the center of the screen is fine....
Thanks! I guess the (0) means the desktop....
Appreciate your help,
ns
|
|
|
|
|
All I want to do is to write a script that will modify they rights of the everyone group. Which you can do on any object by going to it's security page. all I am tyying to do is automate this process which I know is possible because when edit an objects security page all you are doing is executing a series of API functions and any API function is accessible from C++ I know I cannot delete the everyone group but I also know I can assign rights to the everyone group and this is what I want to do. I need to know how to target your harddrives DACL and remove an particular ACEplease help
|
|
|
|
|
:(Hi,
I am having a Property page with an Editable ComboBox, wherein if i press the delete key from keyboard, would delete the item selected in List of Combo Box.(Combo Box List is in Dropped down State)
Requirement:
1. Delete Option will be enabled only when the List of Combo Box is in dropped down state and an item is selected in List of Combo Box(Found Solution)
2. If i type some text in the Combo box window & the list is dropped down and an item is selected using mouse, then delete key is pressed. The item selected would be deleted & the text in window should not be deleted and the focus in text would be maintained. (I am not able to retain the focus of the Text in ComboBox Window)
3. Once the Item selected in Listbox is deleted the List will reduce based on the number of items deleted.
The above point is similar in implementing the Login screen functionality of web Brosers using CCombobox.
I need a solution for this very urgently.
I am enclosing a sample workspace with the above problems indiacted
Regards,
R.S.Velan
Senior Software Engg.
L&T Infotech Ltd...,
Chennai
India
|
|
|
|
|
hi,
i want to know how i can let my network card send raw data(without TCP/IP and that stuff). and of course how to receive it.(OSI layer 3)
and of course... is it possible(because windows already uses the network card)
|
|
|
|
|
Hi all,
Anybody knows how to get the highlighted string from window application? For example, getting the highlighted string from IE or MS Word. I do not have any idea of implement it.
Cheers,
Tony
Enjoy Coding.
|
|
|
|
|
What kind of window? In a generic window you are limited to GetWindowText only.
|
|
|
|
|
:-OThank you for your answer. I am going to do the following works:
1) Highlighted a string in an MS Word document/ MS IE.
2) Press a Hotkey from keyborad to activate my application, and use the highlighted string in step#1 as the input parameter.
Does it possible to be done by VC++?
Cheers,
Tony
|
|
|
|
|
It is possible, but you have to use MS Word(MS Office) COM model.
You should use something like (check the dependencies):
#import "VBE6EXT.OLB"
#import "MSO9.DLL"
#import "MSWORD9.OLB"
After that the whole set of MS Word objects is exposed to your program
|
|
|
|
|
Hello
I got a little routine for checking a date field.
Now i want to automatically set the focus to that field by using f.e:
(where EF_DATUMINDIENST is the name of the text field)
(GetDlgItem(EF_DATUMINDIENST))->SetFocus();
but my idea was of making a function with as param. the name of that text field.
now i set for example a
CString fieldname = "EF_DATUMINDIENST"
and i call the routine here:
DoChecksAndSetFocusAt(fieldname);
but in the routine "DoChecksAndSetFocusAt"
i can't set focus on that control becz it believes it is a CString text
fieldname = result;
UpdateData(FALSE);
This of course doesn't work .. but i have no idea of how to make it work
So i want to access the text field correctly.
Can anyone help me?
Thanks
Jens
|
|
|
|
|
make it : DoChecksAndSetFocusAt(UINT id) and just pass the control ID.
in C/C++, there's no way to go from a string to a variable name at run time.
-c
When history comes, it always takes you by surprise.
|
|
|
|
|
ok thanks, that worked great!
|
|
|
|
|
Ok
I've created a win32 dll project via VS. In this dll I'm creating dialog boxes and windows be be used by several diffent apps.
Here's an example of my creation of the dialogs:
hTemp =CreateDialog(hInstance,
MAKEINTRESOURCE(IDD_USER_STR_INPUT_DLG),
hWnd,
IuxUserStringInputProc);
if (hTemp == NULL)
error = GetLastError();
But it ALWAYS comes back null and the get last error returns an 1814 error, which is: ERROR_RESOURCE_NAME_NOT_FOUND and MSDN tells me: "The specified resource type can't be found in the image file"
What the heck does that mean? It kinda makes sense what it is telling me in that the resource I'm trying to create isn't there in the dll, but it's in the project and it shows up in my build options, so what gives
any help in the matter is GREATLY appreciated.
Thanks
Dan Willis
|
|
|
|
|
groover4life wrote:
hInstance
See MSDN description for CreateDialog, pay attention to the hInstance argument
|
|
|
|
|
Doh!
Makes perfect sense now. LOL. thanks!
Dan Willis
|
|
|
|
|
Ok digging deeper on this problem.
hInstance
Identifies an instance of the module whose executable file contains the dialog box template
since I am calling the CreateDialog within a function in a dll and passing the Hinstance from the application in, it's not the correct Hinstance.
how do I correct this? do I need to create an imaginary window in the dll before calling the CreateDialog and use the Hinstance from that???
This has me a little confused.
Any suggestions? Thanks!
Dan Willis
|
|
|
|
|
hInstanse is the one that comes in DLLMain. Since it is almost first function that is called when DLL is loaded, you can save the value of it in some local variable, at that time.
|
|
|
|
|
I think you can use
(HINSTANCE)GetModuleHandle( _T("Your DLL File Name Here.dll") );
instead of the hInstance of the application . Or, you can just use the saved hInstance value from DLLMain like AlexO suggested.
Chris Richardson
C/C++ Include Finder[^]
|
|
|
|