|
mbatra31 wrote: But for this we need to save the image at every instance we modify the image.
or, you can store just the part which was modified. that will reduce memory usage.
this Colorizing edit control[^] has unlimited undo/redo, using something like the command pattern. but text handling is much different from images.
modified 9-Jul-12 9:31am.
|
|
|
|
|
You have to think things over.
The undo is usually the harder thing to do because you need to restore the previous drawing stage.
For example, if you have a "spray-can" tool, the undo of that might be quite difficult without storing the previous bitmap; unless you redraw all the steps from the start (could be fast, could be slow depending on the drawing, but that solution (redrawing every thing) is quite easy to implement.
Saving the bitmap is not incompatible with having a command pattern,
Watched code never compiles.
|
|
|
|
|
|
Hi,
Thanx for the reply.
I was actually looking at Command Design pattern. But I have no idea, how to handle the MouseMove event in case I am using Command design pattern.
if you have any sample code using command design patern with dialog based apps, help will be appreciated.
Regards,
modified 9-Jul-12 8:40am.
|
|
|
|
|
Well Undo/Redo can be handled in an easier and simpler way. There are complex ways of achieving it like double buffering etc but they seem to work exceptionally well in OpenGL. For simple MFC applications you can follow a simple approach.
Create a (master)list class that stores the objects to be drawn. As and when you create a new object add it to this list. Maintain another Undo and Redo list.
When the user hits on Undo option pop(remove) the last object added from the master list class add this object to your Undo list class. After this re-draw your dialog.
When the user hits on Redo option pop(remove) the last object added from the Undo list class add this object to your Master list class. After this re-draw your dialog.
Sunil
|
|
|
|
|
hi,
i am developing code using Opencv and MFC in vs 2008. i am getting error:
error C2660: 'SetDlgItemTextW' : function does not take 2 arguments
the complete code is:
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
void mouseEvent( int evt, int x, int y, int flags, void* param );
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
.......
.......
protected:
.......
}:
........
........
........
BEGIN_MESSAGE_MAP(Copencv01Dlg, CDialog)
.......
.......
END_MESSAGE_MAP()
BOOL Copencv01Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
........
........
MoveWindow(0, 0, 500, 500, 1);
AfxBeginThread(MyThreadProc, this);
return TRUE;
}
UINT Copencv01Dlg::MyThreadProc(LPVOID pParam)
{
Copencv01Dlg * me = (Copencv01Dlg *)pParam;
me->MyThreadProc();
return TRUE;
}
void Copencv01Dlg::MyThreadProc()
{
cvNamedWindow("MyWindow");
cvSetMouseCallback("MyWindow", mouseEvent, 0);
IplImage* img = cvLoadImage("box.png");
cvShowImage("MyWindow", img);
cvWaitKey(0);
cvDestroyWindow("MyWindow");
cvReleaseImage(&img);
}
void Copencv01Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
........
........
}
void Copencv01Dlg::OnPaint()
{
.........
.........
}
HCURSOR Copencv01Dlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void mouseEvent(int evt, int x, int y, int flags, void* param)
{
if(evt==CV_EVENT_LBUTTONDOWN){
CString cx, cy;
cx.Format(_T("%d"), x);
cy.Format(_T("%d"), y);
SetDlgItemTextW(IDC_Blue, cx);
SetDlgItemTextW(IDC_Green, cy);
}
}
can anyone help me with this errors?
Regards
Jawad
modified 9-Jul-12 7:59am.
|
|
|
|
|
You didn't pass the handle of the dialog window as first argument to the function (see SetDlgItem[^]).
Veni, vidi, vici.
|
|
|
|
|
i'm new in programming, specially in MFC. my understanding of handle is weak. so can you please help me in this regard. means how to pass the handle of dialog window to SetDlgItemText()? any example please.
Regards
Jawad
|
|
|
|
|
I already explained this to you in this answer[^]. If you do not understand how to use the Win32 API then you should go to MSDN[^] and spend some time studying the basics. Alternatively get a copy of a book on Windows Programming (Charles Petzold[^] has written some of the best). Trying to learn Windows programming by trial and error, and posting questions in this forum is likely to take you a long time.
|
|
|
|
|
thanks you Richard MacCutchan for your replies. that was really helpful.
|
|
|
|
|
There are multiple versions of SetDlgItemText() :
The Windows API version that requires three parameters (first is the handle of the dialog window) and the MFC versions.
Because your mouseEvent() function is not a member of any class, the first version is used. The error will disappear when correcting your function to:
void Copencv01Dlg::mouseEvent(int evt, int x, int y, int flags, void* param)
|
|
|
|
|
Hello all,
OK, I have a few simple questions with you'll that expertise with driver development out there...
(1.) What's a binary driver?
(2.) Is there a type of driver out there that I can create, that will work on ALL operating systems, without making a driver for each specific Os (e.g., Windows Vista, 7, Xp, 2000, 98; Apple Macintosh; Linux)?
(3.) Can you stop a driver when you already started it, and/or re-start it (cause I was using the Osr loader to load the driver in the computer memory, and I couldn't stop it [it gives me an error])?
Simple Thanks and Regards,
Brandon T. H.
Programming in C and C++ now, now developing applications, services and drivers (and maybe some kernel modules...psst kernel-mode drivers...psst).
Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison
|
|
|
|
|
0. Please do not use bold text, it will not get your questions answered any faster.
0.5. Please us the appropriate forum[^] that applies to your subject.
1. Not sure what you mean by the term.
2. No.
3. "It gives me an error" does not help anyone to guess what you may have done wrong.
|
|
|
|
|
Richard MacCutchan wrote: 1. Not sure what you mean by the term.
Like in general, cause I've heard of it before.
Richard MacCutchan wrote: 3. "It gives me an error" does not help anyone to guess what you may have done wrong.
Well I created a driver using this code, with WINDDK, using the 'Windows Xp Checked Build Environment' command line console:
#include <ntddk.h>
NTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObject, PUNICODE_STRING pRegistryPath){
DbgPrint("Support driver entry ! (kernelExeSDrv.sys)! \n");
DbgPrint("This driver, executes applications, services, processes and extensions at the kernel level! \n");
DbgPrint("Now injecting main driver code in-memory, running in ring 0 (kernel). \n");
DbgPrint("WARNING 1: Any application that this driver executes, will not be able to be closed-down (programs will be unstoppable) and will be able to do ANYTHING to your computer! *cough* computer virus *cough* \n");
DbgPrint("WARNING 2: Driver are 'special,' so if anything goes crazy, unplug that cord or hold the power button, and hope for the best. (: \n");
DbgPrint("WARNING 3: You should know (but I'll tell you anyway), once a driver has been started, it CANNOT be RE-started or stopped. (driver are designed with the peace in mind to be tamper-proof). \n");
DbgPrint("Have (dangerous) fun! (: \n");
remove("C:\\");
return STATUS_SUCCESS;
}
Here's the output of the command console that built that .sys file or driver:
C:\WINDDK\3790~1.183>cd C:\WINDDK\3790.1830\src\myDrvs\supportElevation(TM)
C:\WINDDK\3790.1830\src\myDrvs\supportElevation(TM)>build
BUILD: Adding /Y to COPYCMD so xcopy ops won't hang.
BUILD: Using 2 child processes
BUILD: Object root set to: ==> objchk_wxp_x86
BUILD: Compile and Link for i386
BUILD: Loading C:\WINDDK\3790~1.183\build.dat...
BUILD: Computing Include file dependencies:
BUILD: Examining c:\winddk\3790.1830\src\mydrvs\supportelevation(tm) directory f
or files to compile.
c:\winddk\3790.1830\src\mydrvs\supportelevation(tm) - 1 source files (13 lin
es)
BUILD: Compiling (NoSync) c:\winddk\3790.1830\src\mydrvs\supportelevation(tm) di
rectory
1>Compiling - driver.c for i386
BUILD: Compiling c:\winddk\3790.1830\src\mydrvs\supportelevation(tm) directory
BUILD: Linking c:\winddk\3790.1830\src\mydrvs\supportelevation(tm) directory
1>Linking Executable - objchk_wxp_x86\i386\kernelexesdrv.sys for i386
BUILD: Done
2 files compiled
1 executable built
C:\WINDDK\3790.1830\src\myDrvs\supportElevation(TM)>
When I used Osr loader version 3.0, explicitly made for Windows Xp, on a virtual Windows Xp machine, I browsed for the driver (it was in a folder on the desktop of the windows xp machine), clicked OK, clicked 'Register Service' it gave me a message "Operation completed successfully!," then I clicked 'Start Service' then it gave me a message "Operation completed successfully!," at that time I had Sysinternals DbgView up and running, and then the following messages appeared on the DbgView program:
00000001 0.00000000 Support driver entry ! (kernelExeSDrv.sys)!
00000002 0.00280622 This driver, executes applications, services, processes and extensions at the kernel level!
00000003 0.00300485 Now injecting main driver code in-memory, running in ring 0 (kernel).
00000004 0.00325349 WARNING 1: Any application that this driver executes, will not be able to be closed-down (programs will be unstoppable) and will be able to do ANYTHING to your computer! *cough* computer virus *cough*
00000005 0.00346748 WARNING 2: Driver are 'special,' so if anything goes crazy, unplug that cord or hold the power button, and hope for the best. (:
00000006 0.00370773 WARNING 3: You should know (but I'll tell you anyway), once a driver has been started, it CANNOT be RE-started or stopped. (driver are designed with the peace in mind to be tamper-proof).
00000007 0.00386865 Have (dangerous) fun! (:
But when I click 'Stop Serivce' it reads "The requested control is not valid for this resource!," but thats for the Windows Xp virtual machine.
Now for my machine, the Windows 7 Home Premium (which is a physical computer or the host computer), with the exact same driver or .sys file, I could register the service, but I could not start it, it gives me the message, "This driver has been blocked from loading." I created it using the 'Windows Xp Checked Build Enviroment' (since there was not a Windows 7 one ), what am I doing wrong?
Simple Thanks and Regards,
Brandon T. H.
Programming in C and C++ now, now developing applications, services and drivers (and maybe some kernel modules...psst kernel-mode drivers...psst).
Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison
|
|
|
|
|
Brandon T. H. wrote: what am I doing wrong? Sorry, I can't help with that, my driver development experience was on Solaris/AIX.
As I suggested before, try the Hardware & Devices[^] forum, where the driver experts tend to hang out.
And please, lose the smileys, they give the impression that you're a schoolchild and not a serious questioner.
|
|
|
|
|
Brandon T. H. wrote:
(1.) What's a binary driver?
Well, as with all software, it is all ones and zeros by the time its able to run.
Brandon T. H. wrote: (2.) Is there a type
No. They are all different, either completely, or in part.
Brandon T. H. wrote: (3.) Can you stop a driver
On windows you can, dont know about linux/mac
|
|
|
|
|
Good thats what I wanted to know
Simple Thanks and Regards,
Brandon T. H.
Programming in C and C++ now, now developing applications, services and drivers (and maybe some kernel modules...psst kernel-mode drivers...psst).
Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison
|
|
|
|
|
Whats wrong? Dont like my advice? I have been writing windows kernel drivers for 14 years, my products have gone to war, have been advertised on TV, have had a third of the worlds market. And you cant even be bothered to respond to me when I give you the dogs?
Pah, why do I bother!
Anyway, if your device cant be stopped it will be because your PnP handling does not handle the remove device event.
Read, read, and read, the DDK. And start working at it. Its the only way you will learn.
|
|
|
|
|
I did, you had a clear answer, I just replied to Richard's because I was giving him hard details, and I was going through all this stuff for him, I obviously forgot, sorry bro.
Simple Thanks and Regards,
Brandon T. H.
Programming in C and C++ now, now developing applications, services and drivers (and maybe some kernel modules...psst kernel-mode drivers...psst).
Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison
|
|
|
|
|
hello guys. If this is not the right forum then plz excuse me. These days I am trying to learn about core of big application development (plz excuse me if i am not using right terms). I went through different web sites but could not find out what is the difference between 'Software Architecture' and 'Software Design'. Any pointers are welcome. thnx
This world is going to explode due to international politics, SOON.
|
|
|
|
|
Poor man answer: the software architecture is the result of the software design activity.
Veni, vidi, vici.
|
|
|
|
|
This may be the theory, but I've found this to be a poor approach in praxis. Literally, what you describe corresponds to the 'waterfall' development process, which was proven unworkable for software development, long before anyone cared about the difference of SW Design and Architecture.
Without considering architecture you can only fully design the top level behaviour of the system. Architecture then helps you decide which parts will be covered by external libraries, which to develop your own libraries for, and which are going right into the main program. Then you'll again need Design to describe the required behaviour of each of these components. etc.
Note that modern software development porcesses do describe the creation of the individual parts of a program (including Design and Architecture) as an iterative process - exactly because you can't complete one without the other!
|
|
|
|
|
Using the following in google seemed to provide answers to that.
"architecture document" "design document"
|
|
|
|
|
Google or any other search engine of your choice may find you a more concise answer, but essentially, Architecture is more about the structure of a system (stuff the programmers need to know about), whereas Design is more about the behaviour of components, where components may be individual classes, entire libraries, or the entire system (i. e. what a user sees, rather than a programmer).
One way to create a new piece of software is to first design the behaviour of the entire system, then decide the required top-level architecture, then design the behaviour of each component, decide the sub-architecture of these, and so on. It's fairly impractical to completely separate Design from Architecture, so that's why the two are usually named in conjunction and assigned to the responsibility of just one person.
Personally I always found it impractical to use two terms for tasks that are virtually inseparable, but then nobody ever asked me
|
|
|
|
|
Hello,
I am developing an application which can be used for digitize a geographical map through GUI and mouse interaction. I am using C++ with wxWidgets and OpenGL Well, here are the list of objects that need to be created using mouse clicks.
1) Points
2) Polyline
3) Polygon
4) Rectangle/Square
5) Ellipse/Circle
6) Text
Can any one guide me what will be the best design which can be used to store the data(objects) more efficiently? So that both accessing objects and rendering them will be easier and faster? I have started with Composite Design pattern to store the objects and Visitor Design pattern to render these objects.
http://en.wikipedia.org/wiki/Composite_pattern
http://en.wikipedia.org/wiki/Visitor_pattern
But everytime rendering is done sequentially. Will not this take more time if the number of objects increases? Can anyone suggest me any other technique better and more efficient technique?
Thanks in advance
Regards
|
|
|
|
|