|
Hi all.
I really need how to do this fast:
How do we draw lines that we can pick and move?
I need to store their start and their endpoint.
Can somebody help me please?
aartee.
|
|
|
|
|
Point start, end;
You need to store two points, keep track of when the mouse is near them to 'pick them up', and move them when they are being held by the mouse. It's a fairly basic problem, just think about it in terms of what messages you can catch from your MFC app, and how they relate to what you want to do. Your OnPaint will always draw a line between the points, then you just need to catch mouse clicks when the pointer is near a point, move the point in OnMouseMove, and let go when the mouse button is lifted.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi Christian
But how can a simple point catch an event?
Is it really so simple?
Do I not need to implement it as some type of control or whatever?
Thanks,
aartee.
|
|
|
|
|
No, it's easy as pie. When you click the mouse, your app gets a message which includes the position of the mouse. Same when you move the mouse or lift the button. You just need to call a method to turn the position relative to the top left corner of the screen to a position relative to the top left corner of your window.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
One more question:
how do we store the lines so that when we change the positions of the line we can update our positions stored for that line accordingly.
I mean, if we store the lines in a list, how do we know at node in the list the line is so that the information at that node can be updated?
-Aartee.
|
|
|
|
|
When you click the mouse, you iterate through the list until you find a point that corresponds to where the person clicks. Then you remember that this is the item you're working on and change it's values. I guess the best bet is to use a list and keep an iterator as a member variable.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
hi everyone..
while working and not going to faculty this year, i want to create a c++ project with mfc to refresh my c++ memory.
i would like to create a multiple richedit document view with splitter window and the listview/window explorer view on the left...
all i want to know at the moment is, how to start creating a project like that?
should i do mfc app wizard with richeditview and then try to add explorer view on the left? if so, how should i do that?
help me out.. i'm lost.
thanks to all. awesome site btw
regards
|
|
|
|
|
You didn't say which version of VC you have, but in v6 the AppWizard can make a splitter with a tree on the left for you.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
There is a saying in statistics that a million monkeys pounding on typewriters would eventually create a work of Shakespeare. Thanks to the Internet, we now know that this is not true.
|
|
|
|
|
well..
i have vc++ 6.0
and when going thru wizard, i just know, it asks me, how do i want my application to look. mfc or explorer style. and if i do explorer style, how to change the main view then to richedit box?
thanks.
|
|
|
|
|
|
Hello.
Where is the option to view and debug source code directly in assembly mode via the Disassembly Window in Visual C++ .NET? Older versions including 6.0 has a menu item, View->Debug Windows->Disassembly.
Thanks,
Kuphryn
|
|
|
|
|
Whilst running in Debug mode, choose Debug->Windows-Disassembly, or alternatively press CTRL+ALT+D. The Disassembly mode is unavailable in Design (coding) mode. You must run the debugger in order to show/hide this window.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Okay. Thanks.
I still cannot view the assembly code in debug mode. The error is "(Disassembly cannot be displayed in run mode.)." The problem is you cannot "debug" a module without running it.
I need to be able to see the assembly code line by line.
Kuphryn
|
|
|
|
|
This is because you are "live" running the program in debug mode. In order to see the disassembly, you must set breakpoints into the code and fill the necessary requirements for the breakpoint to be reached (For example, if you set a breakpoint to a button click, you must manually click the button in order to reach the breakpoint).
If you want to step through the entire code in debug mode, you must first run the program, then choose Debug->Break All, and Debug->Restart. This will take you to the first line of assembly code in the program, and you can use F10 to step forwards through the code.
The reason why the assembly code is not shown while the program is 'live' is simple: the code would run before your eyes way too fast for you to follow it. That is why you must set breakpoints. When a break is reached, the cursor will stop on the line where the break is, and the disassembly window will show the assembly code lines residing in the vicinity of this code line, namely, the codes required to execute this procedure.
So, you can only see the assembly code line by line if you set a breakpoint and the code reaches this point. If you want to step through the entire program (which will take AGES), then use Debug->Start, Debug->Break All, Debug->Restart.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
|
hi,
i got the memory from heap using 'new' operator.when i delete it using 'delete' , it gives me error message _BLOCK_TYPE_IS_VALID(pHead->nBlockUse).what could be the reason of this problem.
thanks in advance.
kmirza
|
|
|
|
|
Are you sure that you are not deleting the same memory pointer twice???
or are you deleting the pointer in another thread and created it another thread?
or are you allocating the pointer in .exe file and deleting it in the dll ?
All the above cases can lead to problems.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
Hi all,
When using the CreateThread within a class, is it possible to provide a method of the class as the lpStartAddress?
m_hBroadcastThread = CreateThread(0,0,<br />
(LPTHREAD_START_ROUTINE)BroadcastThread,<br />
0,0,&id);
... where BroadcastThread is the name of a method within the class. It's header is as follows:
DWORD CNotificationsHandler::BroadcastThread(LPDWORD param)
I keep getting the following compiler error:
error C2440: 'type cast' : cannot convert from '' to 'unsigned long (__stdcall *)(void *)'
Your help would be greatly appreciated.
Mark
|
|
|
|
|
If the thread method is in the class then it should be declared as static.
The member functions of the class has the calling convention as thiscall too, which need to be removed by making it static.
and while creating the thread pass 'this' pointer to the thread so that the thread function can access the member functions and variables of the class.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
Worked wonderfuly.
Thanks
|
|
|
|
|
|
Also, if you are using the C Runtime Library AT ALL, you might want to be using beginthreadex instead of CreateThread. CreateThread does NOT initialize some thread local data used by each thread in the C run time library.
|
|
|
|
|
hi
i have a CRichEditCtrl in my app and it can't open UNICODE files properly (opens ANSI files ok). what do i have to do ?
here's part of my code:
CRichEditCtrl * richedit = (CRichEditCtrl *)GetDlgItem(IDC_RICHEDIT1);
CFile file(filename, CFile::modeRead);
EDITSTREAM es;
es.dwCookie = (DWORD) &file;
es.pfnCallback = MyStreamInCallback;
richedit->StreamIn(SF_TEXT, es);
richedit->SetReadOnly();
the callback is straight from msdn i think ..
static DWORD CALLBACK
MyStreamInCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
CFile* pFile = (CFile*) dwCookie;
*pcb = pFile->Read(pbBuff, cb);
return 0;
}
|
|
|
|
|
If you know it's UNICODE for certain, and you also know it's a RichEdit v2.0 or later, then try
richedit->StreamIn( SF_TEXT|SF_UNICODE, es );
instead.
(This isn't in the on-line help for CRichEditCtrl, but it is for EM_STREAMIN in the platform SDK docs)
Steve S
|
|
|
|
|
thank you.
now i have to find a way to check if the text is unicode or not - istextunicode() doesnt seem to work correctly
|
|
|
|