|
How do i that ? Can you show me few examples ?
|
|
|
|
|
you can find many article in the code project describing button owner drawing. search "owner draw button" in code project.
nave
|
|
|
|
|
|
Alright, this may be one of those annoying "how long is a piece of string" questions, but I'm just curious if anyone can give a short but key explanation of
- MFC, Win32. I've seen articles saying MFC is "bad" but not really sure why, I've knocked up many things with the app wizard - dialog apps, and to be honest, probably don't really understand the difference between the two, much less why one is better than the other. I'm sure I've also written stuff in Win32 when I wrote tools for 3DSMax but I've been out of programming for a long while, and probably only ever "knew what I needed to know" when I was doing it. Both MFC and WIn32 use C++ as their core?
- I always assumed this C# and .NET stuff were just an extension of Visual C++ but I can now see I'm very wrong - it's a whole new syntax of code. Is this the best place to start now for writing quick and simple tools/applications?
|
|
|
|
|
I think the main reason people would consider MFC bad and the .Net framework good is that MFC has gradually evolved and expanded over the lifespan of Windows, and so has many weird inconsistencies (e.g. if one function returns a colour, and another takes a colour as an argument, you may find that these colours are different types, so you need to convert between them.)
.Net was developed from scratch from the ground up, so is far more consistent (and thus easier to learn if you've got no prior knowledge of the system - from my experience usually if something looks like it's the right way of doing things, it should work)
Of course, in 25 years, we'll probably be complaining about how bloated and convoluted .NET v12 is, and looking forward to whatever new framework is coming out
|
|
|
|
|
ldsdbomber wrote: MFC, Win32
I won't enter the debate to say if MFC is good or not but I'll try to clarify some points here. The Win32 API, honnestly we don't care if it is written in C++, in assembler, in C or whatever. You just acess a kind of interface (a set of function that lets you interract with the core of windows).
MFC is in fact a bunch of classes that wraps the win32 API and it does a lot of things for you. Honnestly, developping an application in pure win32 takes much much much longer than using MFC. But it doesn't mean that MFC is better than win32. No, it just means that MFC wraps the win32 API
For your second question, I know nothing about .NET so I cannot really help you.
|
|
|
|
|
From my experience, many people don't like MFC mostly because it has some ugly syntax conscerning with so many identifiers and macros, and thus makes the programming not easy. And also some say that there are areas where MFC cannot help, so they turn to other libraries or Win32 itself. But let's not forget the purpose of MFC; it is not an all-purpose but a general-purpose library. If we use MFC in an app, this does not mean that everything should be done in MFC and only in MFC. Rather, we are supposed to use other tools as well, and the main one is Win32 functions [that are not wrapped by MFC].
.NET is an another kind of thing. It is an all-purpose library [though we may call Win32 functions as well]. Actually, .NET is a platform with its own interpreter/compiler and executable code. Everything is managed by CLR (Common Language Runtime)...
For Web based apps ASP.NET is much more comfortable than any other tool [IMO].
For large systems [scientific ot other] I don't think that .NET will do much. On the other hand, C++ based apps [consider MFC also] are the leading ones.
--
======
Arman
|
|
|
|
|
People call MFC bad sometimes because you cannot say it's one of the best Frameworks ever built. It's not perfectly planned. Moreover it's a just wrapper around the Win32 API. If you can do everything so easily(if you so proficient) using Win32 SDK , you can very well write your own classes around and use it. Anyway it's going to take more time than doing by MFC. When you compare MFC with .net you'd rather call MFC as a shortcut to Win32 SDK. .Net is quite robust. A fully planned framework. Even it's going to make API calls underground but the difficulty is completely abstracted to the programmer. The big catch in .net is that it compiles to IL rather than the native machine code. The CLR (the .net runtime) *manages* the IL very well and executes it properly. In short, if you program using .net , your application would be completely controlled & protected by the CLR. that's cool.
Dario: How is "directory" in French? (I mean a file system directory).
John Simmons: "zee file holdaire thingie"
|
|
|
|
|
I recall seeing an example somewhere that showed you how to monitor windows messages so that you could do things in a dialog (maybe the example had loads of controls) and either a popup or some text control displayed the WM_ windows message that had been put into the queue as a result. I would love to see that again as it's a great way to learn how things work in a dialog in terms of events and messages.
|
|
|
|
|
Ate you thinking of the Spy++ tool that comes with Visual Studio (it should be in the tools menu)
|
|
|
|
|
If it's MFC, you could be talking about a PreTranslateMessage ?
Dario: How is "directory" in French? (I mean a file system directory).
John Simmons: "zee file holdaire thingie"
|
|
|
|
|
Just wondered if I could get some input/feedback on what is considered to be good style/method for the following
Say I have a simple dialog application created through the app wizard in VC++ (MFC)
If I have three edit boxes which contain variables that (at the moment) users manually input data into, and in a fourth control (edit box, static text or whatever) the value is calculated based simply on the values in the 3 edit boxes.
Is it best just to have a specific button to "calculate" and fill in the 4th control with the answer,
or is there a way to make it automatically update whenever one of the edit boxes changes value - in that case, does this require the user to enter the value and press "enter", or can it be done (and is it more messy?) in real time so that even as you type in a value into one of the edit boxes, the calculated item is updated visually at the same time.
I'm guessing the latter is going to be more of a mess and probably not as useful as it seems, but I welcome any thoughts from anyone who's developed this kind of behaviour before. I assume there might be some message handler for the edit boxes like WM_ITEMCHANGED or something, will look in MSDN but please feel free to contribute
many thanks
|
|
|
|
|
when ever the text inside an edit comtrol changes, the parent window will get the EN_CHANGE notification.
So take classwizard and add EN_CHANGE event handler for each edit control.
nave
|
|
|
|
|
ldsdbomber wrote: Is it best just to have a specific button to "calculate" and fill in the 4th control with the answer,
Probably, as it is the simpler logic, and the user knows this behaviour from calculators and such.
But both automatic variants are possible. You would need to handle EN_CHANGE or even EN_UPDATE. I have done this once and it turned out to be a real mess with circulating updates and such.
So, with a "calculate" button you probably do nothing wrong and keep your program simpler.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
Hi All
I am using ShellExecute, to run 4 command line prompts from an applications
what i would like is to run each command sequentially one after the other,
each command probably takes 3-4 seconds to run, but what seems to be happening
is all 4 commands end up running at same time, so while the first command is still running, the fourth one has already been executed
what would be the best way to make shellexecute wait until the process it calling has finished before it moves onto the next ?
hope that makes sense
Simon
|
|
|
|
|
I think you can create a .bat batch file where you can specify \wait between processes. Then shellExecute the batch file from your program.
Dario: How is "directory" in French? (I mean a file system directory).
John Simmons: "zee file holdaire thingie"
|
|
|
|
|
|
If you use ShellExecuteEx() or CreateProcess() , you can then employ WaitForSingleObject() to wait for the process to finish before starting another.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
A few days before i asked about a library or document link to handle polygons, so far without answer, so I think I'll ask some more specific questions, and see if anyone can help me...
Current problem is how to select and activate a polygon. I built up a CTypedPtrList that holds Polygons, which consist mainly in a CList of CPoints (like in the scribble tutorial, but instead of CStrokes I use my own Polygon class). That helps me as far as drawing the polygons with CDC::Polygon command, but to move and manipulate the Polygon the next step is to let the user select one by mouseclick.
And here the big problem comes to light: how can I select a polygon (whose data structure exists as a series of points) by only knowing where the user clicked? Are there special commands (like drawing the polygon with CDC:Polygon) to know wether a given point is in the "inner" area of a polygon giving the clicking position and an array of CPoints? Do some special commands exist that can detect the whole polygon by giving a point in or near the polygon?
And with editing a polygon some similar questions arise when trying to detect which vertex of the polygon was chosen to move/delete or which line to insert a new vertex.
And one more question about drawing the polygon: is there a way to fill the polygon with a transparent brush, e.g. a hatching that let the structure of polygons below that shine through?
Can anyone help with these problems or suggest any good readings in that topic? Any help is appreciated, but please keep in mind that I'm still learning programming under Windows/MFC, so don't expect knowledge too deep in MFC technology.
Martin Dietz
|
|
|
|
|
Finding if a point lies within a polygon is not an easy task. There are some algorithms that exist and you can have a look here[^] for example (or just google for "point inside polygon").
What I would typically do, is adding a method to your polygon to check if a point is inside itself (something like IsPointInside(CPoint point) ). Then, you can iterate through your polygon list and call this function for each polygon and stop once you find one.
|
|
|
|
|
Hello,
I am just writing out what i have in my memory, so i wont be able to give exact references.
First of all, i think in GDI regions might help you since it should have PointInside method as far as i remember. If you want to use an algorithm, check Point inside polygon methods on Internet, Graphics Gems and Computational Geometry in C by Rourke and other books can help. I believe Chris Maunder has a polygon class and implements a method, check codeproject for Computational Geometry Classes by Chris Maunder.
i dont have much experience on the selection of points and lines, but there should be an article in MSDN explaining it.
Hope this helps.
Bekir.
|
|
|
|
|
I found under CRgn the possibility to create a Region by polygon (same way as to draw one) so I can use the PtInRegion-function. For the selecting points and lines parts, I'll look for the articles you mentioned. Thanks so far.
Martin Dietz
|
|
|
|
|
For simple hit-testing, CreatePolygonRgn() and PtInRegion() work well.
Mark
|
|
|
|
|
Please Refer Here[^]
This doesn't work there:
if (mySObj_iter != lst_mySObj.end())
{
lst_mySObj.erase(*mySObj_iter);
}
How do I do it?Overload any other operator?
Error:
<br />
error C2664: 'std::list<_Ty>::_Iterator<_Secure_validation> std::list<_Ty>::erase(std::list<_Ty>::_Iterator<_Secure_validation>)' : cannot convert parameter 1 from 'myStruct' to 'std::list<_Ty>::_Iterator<_Secure_validation>'<br />
with<br />
[<br />
_Ty=myStruct_t,<br />
_Secure_validation=true<br />
]<br />
*
|
|
|
|
|
Astricks wrote: lst_mySObj.erase(*mySObj_iter);
Did you even bother to read the MSDN helptext?
Or a good Book?
Josuttis, "The C++ Standard Library" and
Myers, "Effective STL"
are always within arms lenght here.
The correct parameter is the iterator, not the object.
So stop dereferencing the iterator and write
lst_mySObj.erase(mySObj_iter);
-- moified at 4:43 Monday 12th February, 2007
Clarification
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|