Click here to Skip to main content

Comments by Hans Dietrich (Top 123 by date)

Hans Dietrich - 16 Jul '11 - 18:16 View
Reason for my vote of 5 This is such a great idea! Each category should have a Tip like this.
Hans Dietrich - 21 May '11 - 22:14 View
Yes, and could you double-size me, too?
Hans Dietrich - 20 May '11 - 19:19 View
I believe the OP is saying that he doesn't have a handle to the current app window, and therefore must pass NULL to MessageBox; this does *not* result in app-modal behavior, unless you use the option I mentioned.
Hans Dietrich - 20 May '11 - 17:54 View
Yes, I think MessageBox will do what he wants, if he chooses the right set of options.
Hans Dietrich - 20 May '11 - 8:32 View
Please take a look at MB_TASKMODAL option of MessageBox().
Hans Dietrich - 20 May '11 - 8:32 View
Please take a look at MB_TASKMODAL option of MessageBox().
Hans Dietrich - 17 May '11 - 4:30 View
Good answer.
Hans Dietrich - 16 May '11 - 4:40 View
You are correct; one has to give attention where there is best opportunity to help and to teach. At the same time, I refuse to be be judgmental. My choice of which question to answer does *not* mean other questions do not deserve a serious, professional answer.
Hans Dietrich - 14 May '11 - 18:41 View
I did my best to understand that the OP had a real question. I don't think a lack of vocabulary should be penalized. So, as always, I believe there is no such thing as a bad question, although in this case it could have been phrased a little better.
Hans Dietrich - 14 May '11 - 18:36 View
Evil. God will get you for this.
Hans Dietrich - 10 May '11 - 23:30 View
Agree. Letting the system choose the processor is nearly always the right way. Great links. My 5.
Hans Dietrich - 10 May '11 - 23:26 View
Accurate, complete answer. My 5.
Hans Dietrich - 10 May '11 - 20:46 View
I'm not sure what you mean by "trusted", but be aware that there are utilities freely available that can be used to change the HD serial number. So while you can get the current serial number, don't think it can't change.
Hans Dietrich - 9 May '11 - 8:49 View
Nice link. My 5.
Hans Dietrich - 8 May '11 - 3:54 View
I love one of the user comments on that MSDN page: "This program doesn't work on Windows 7 machine, when trying to get information from a UNIX machine."
Hans Dietrich - 5 May '11 - 15:33 View
Thanks. I used to use windbg a lot, but the VS debugger has improved quite a bit over the years (unlike the IDE :) ).
Hans Dietrich - 5 May '11 - 5:40 View
Good complete answer. My 5.
Hans Dietrich - 4 May '11 - 0:04 View
There are extensions that provide this: http://www.han-soft.com/uninshs.php
Hans Dietrich - 2 May '11 - 21:31 View
Have you checked with the manufacturer of the projector?
Hans Dietrich - 2 May '11 - 11:46 View
Take another look at your function f. If i is NOT equal to 0, what is returned?
Hans Dietrich - 2 May '11 - 4:56 View
Unless it's a static, like Alain says.
Hans Dietrich - 2 May '11 - 4:03 View
Your statement is asinine. This thread is about languages, not compiled binaries. If you think C++ is dependent on the platform, then you should stick with java, because you don't know sh*t about C++.
Hans Dietrich - 2 May '11 - 2:09 View
I have seen a lot of blogs about MS Office and wine. For some people, it works; for others, it consistently crashes. If you know of a good beginners tut for wine, maybe you can post the link here, so the OP can try it for himself?
Hans Dietrich - 2 May '11 - 1:51 View
Correct, my 5.
Hans Dietrich - 2 May '11 - 0:35 View
Who cares?
Hans Dietrich - 30 Apr '11 - 21:26 View
I know you didn't; but from the 1-votes other people obviously thought that.
Hans Dietrich - 30 Apr '11 - 15:32 View
Thanks. Some people would associate lack of knowledge with being stupid, but I am willing to believe this was an honest question, from someone with little exposure to the subject. There's no reason not to encourage people like this.
Hans Dietrich - 30 Apr '11 - 0:27 View
I agree. This is a level of knowledge that comes before questions such as, How do I play a WAV file? We were all here at one point, so we shouldn't be surprised to find others here now. :)
Hans Dietrich - 29 Apr '11 - 23:50 View
I look at it as *before* the good and evil. I mean, there was a time when I didn't know what ASCII was. I know, I know; a little removed from COM interfaces and .NET interop. I'm not even sure if there are any articles on CodeProject that would help the OP. And if there were, they would probably be downvoted out the wazoo, what with our lovely voting system.
Hans Dietrich - 29 Apr '11 - 19:21 View
Well, the problem with that, is that the OP would need *two* collections, to match the gender preference of the interviewer. Maybe a Ctrl-key combo switches between them for demo purposes.
Hans Dietrich - 28 Apr '11 - 16:57 View
I had a similar problem with an MFC app that used the Feature Pack ribbon stuff. You may have to use SetWindowPos to make it top-most, redraw the window, and then call SetWindowPos again to make it non-top-most.
Hans Dietrich - 28 Apr '11 - 15:26 View
Right, because you said "I don't want it to be top most permanently". BringWindowToTop() will bring it to the top, without making it a top-most window. Did you try it?
Hans Dietrich - 26 Apr '11 - 22:45 View
Good answer, my 5.
Hans Dietrich - 26 Apr '11 - 17:35 View
Yes, exactly.
Hans Dietrich - 26 Apr '11 - 17:17 View
If you have created a Windows dialog-based app, just use ::MessageBox() to display the info in InitInstance() and then return - don't display the dialog.
Hans Dietrich - 26 Apr '11 - 15:31 View
I suggest you give QuickWin a try first - it's very simple to use. After that, you could go with a "real" Windows app if you needed to. Post a new thread if you want to do that.
Hans Dietrich - 26 Apr '11 - 15:18 View
MUST.NOT.SAY.DOS.BOX!
Hans Dietrich - 26 Apr '11 - 14:46 View
Good guidance, Nish.
Hans Dietrich - 26 Apr '11 - 14:26 View
Edited for grammar and SMS speak.
Hans Dietrich - 25 Apr '11 - 18:53 View
Very true!
Hans Dietrich - 24 Apr '11 - 18:39 View
Wow. Never heard of it before.
Hans Dietrich - 19 Apr '11 - 9:39 View
Maybe two people in the same class? :)
Hans Dietrich - 19 Apr '11 - 4:25 View
It's actually very well-written and fun to read.
Hans Dietrich - 19 Apr '11 - 2:52 View
That's exactly what it means. IMHO, Fred Brooks is a clown. If you read his famous book carefully, you will notice two things: 1) he is a good writer; and 2) he was in charge of one of the worst-managed computer projects ever. He did all the wrong things; he made every bad decision possible; he kept repeating these mistakes throughout the project. The project was completed in spite of him, not because of him. That he garnered so much fame for it is a joke.
Hans Dietrich - 19 Apr '11 - 2:21 View
I thought it was very good. The author makes the point that in any field, to be good at it one must learn the basics. Every day I talk to and work with people who have skipped this step, and treat programming as a cookbook art; they are able to do routine stuff, but anything non-routine is totally beyond them. Even worse, they don't seem to understand that they are writing code not for themselves, but for the maintenance programmers who will follow them, and have to figure out what they have written. Very few of them would be able to tell you what it means to write maintainable code.
Hans Dietrich - 19 Apr '11 - 1:59 View
Your English is fine, but use of "sms speak" (like "plz") is discouraged on these forums. Please have the courtesy to use standard English.
Hans Dietrich - 19 Apr '11 - 1:52 View
Except for the reference to Fred Brooks, an excellent link.
Hans Dietrich - 19 Apr '11 - 0:22 View
Microsoft bought code from BCGSoft and renamed it MFC Feature Pack.
Hans Dietrich - 18 Apr '11 - 11:40 View
The standard practice when working with "unknown" strings is to set the last character to zero after the copy. (I see this done on Unix more than on Windows.) Yes, the _s functions are nice this way, but to claim they are safe is a joke. See for example, Danny Kalev's analysis here: http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=260
Hans Dietrich - 18 Apr '11 - 10:05 View
Since this is usually specified in stdafx.h and not in the source file, it is a Bad Idea. What if you were to take the source file and use it in another project, months from now? Then you would have to spend time trying to figure out why you get the warning on one project, but not another. If you want to be proactive about this warning, then do what I do; put this pragma at the top of each source file where needed: #pragma warning(disable : 4996) // disable bogus deprecation warning Note that I say "bogus" because that's exactly what it is; you can achieve the same effect from using strncpy(). Yes, you can be wrong about the length parameter in strncpy, just like you can be wrong about the length parameter in strcpy_s. With both functions, you have to be careful.
Hans Dietrich - 18 Apr '11 - 9:57 View
In general, unless there is no alternative, it's a Bad Idea to change the project properties just because of what's in a source file. What if you were to take the source file and use it in another project, months from now? Then you would have to spend time trying to figure out why you get the warning on one project, but not another. Even worse, what if someone else changed the properties, and you were not aware of it? Waste of time.
Hans Dietrich - 17 Apr '11 - 22:48 View
If that's true, then why didn't OP report an error on that line?
Hans Dietrich - 17 Apr '11 - 12:49 View
The OP didn't say he got an error on this line: if( this->m_StudentName == "" ) so he must not be using Unicode.
Hans Dietrich - 16 Apr '11 - 0:59 View
This is what I was going to say, but you beat me to it. My 5.
Hans Dietrich - 13 Apr '11 - 20:31 View
I'll bet you a beer the next MS OS will include the VS6 MFC DLLs.
Hans Dietrich - 13 Apr '11 - 9:24 View
Googlé
Hans Dietrich - 13 Apr '11 - 8:13 View
Exactly, which is what I said in my Solution 1.
Hans Dietrich - 13 Apr '11 - 7:55 View
If the message map entry or message handler is missing, it would be passed to default handler, which would close it.
Hans Dietrich - 11 Apr '11 - 22:19 View
A preprocessor macro is just that - it gets interpreted before the compile. So at run-time, a preprocessor macro has already come and gone, and can't possibly do what you want. You need something that runs at run-time, that will choose the correct code to run.
Hans Dietrich - 11 Apr '11 - 19:04 View
:) Who knows? He may learn something anyway!
Hans Dietrich - 11 Apr '11 - 4:15 View
OK, no problem.
Hans Dietrich - 11 Apr '11 - 3:48 View
That would depend on the code in the function.
Hans Dietrich - 10 Apr '11 - 23:27 View
Classic! This one should go to Q&A Hall of Fame.
Hans Dietrich - 10 Apr '11 - 11:38 View
Gave you a 5, one of my favorite tricks.
Hans Dietrich - 10 Apr '11 - 9:16 View
Yes, I use this too. Since it was a newbie question, I wanted to stick to the basics.
Hans Dietrich - 10 Apr '11 - 9:13 View
Brilliant! I now have a new goal in life!
Hans Dietrich - 10 Apr '11 - 3:53 View
To shortcut the back-and-forth, I have created a demo that shows how to display a dialog from a DLL, Please download it here: http://www.hdsoft.org/download/MfcExtDllTest.zip Please post here if you have questions.
Hans Dietrich - 10 Apr '11 - 1:47 View
It sounds like you have a dialog class in your DLL. Is that correct? If it is, then yes, you have to create an instance of your class. "MydllDlg.cpp" is a filename. This tells me nothing. Does it contain an implementation of a dialog class? Please show the contents of mydll.h.
Hans Dietrich - 10 Apr '11 - 0:17 View
If you are just trying to call a function in the DLL, then all you have to say is myfunct(); with the appropriate parameters, of course. Since you haven't shown any code, or said what was in the DLL, this is my best guess.
Hans Dietrich - 10 Apr '11 - 0:16 View
If you are just trying to call a function in the DLL, then all you have to say is myfunct(); with the appropriate parameters, of course. Since you haven't shown any code, or said what was in the DLL, this is my best guess.
Hans Dietrich - 7 Apr '11 - 0:21 View
It's sad, pathetic, idiotic. I run out of words to describe.
Hans Dietrich - 6 Apr '11 - 23:31 View
:) :) :) Personal experience - from staring at a dozens of comboboxes and wondering why the listbox wouldn't drop!
Hans Dietrich - 6 Apr '11 - 22:09 View
No, SHGetFolderPath works fine on Win7. It's the MS-recommended alternative that does not work prior to Vista.
Hans Dietrich - 6 Apr '11 - 10:10 View
You're welcome!
Hans Dietrich - 6 Apr '11 - 9:48 View
The file memdc.h is from an article here on CP. Then MS came up with their own class, and called it by the same name!@&*$!! Easiest fix: rename memdc.h to xmemdc.h, and rename the class to CXMemDC (naturally, the MS version is not compatible).
Hans Dietrich - 6 Apr '11 - 6:48 View
It seems like this goes in cycles. First, we had INI files. Then that was bad (per MS), we should use the registry. Then with .NET we're told to use config files (aka INI files). I suppose it will be The Cloud next. :)
Hans Dietrich - 6 Apr '11 - 2:10 View
Hi Neil, (You responded to your own message rather than mine, so I did not get the notification.) I have always found the CButton class to be annoyingly limited. In fact, I wrote my own XButtonXP class to get around some of these problems. Having said that, I can't say that you can't do what you want with CButton; I have just not seen it done. Maybe someone else can give you a better link.
Hans Dietrich - 5 Apr '11 - 18:46 View
Correct, my 5.
Hans Dietrich - 2 Apr '11 - 10:43 View
Most of these books are available used, very cheap. The fundamentals of MFC have not changed that much since VS6, so don't think that these books are obsolete. What has changed in MFC are some new controls, that you will find described on the internet. Another thing to consider if you really want to understand MFC: it is a thin wrapper of many Win32 functions, including GDI. Quickly reading through the Petzold book will give you a feel for what GDI is, and how MFC wraps its functions. Petzold - every Windows programmer should read this at least once (non-MFC): http://www.amazon.com/Programming-Windows-Microsoft-Charles-Petzold/dp/157231995X/ Two very good basic MFC books: http://www.amazon.com/Programming-Windows-Second-Jeff-Prosise/dp/1572316950/ http://www.amazon.com/Professional-MFC-Visual-C-6/dp/1861000154/ A more advanced MFC book: http://www.amazon.com/MFC-Internals-Microsoft-Foundation-Architecture/dp/0201407213/ Intermediate to advanced GDI book: http://www.amazon.com/Windows-Graphics-Programming-Hewlett-Packard-Professional/dp/0130869856/ Finally, don't forget that reading code - like in the articles published here - is a great way to learn. Good luck.
Hans Dietrich - 2 Apr '11 - 7:05 View
Don't you keep a list of the drawing objects? Simply repaint the list in OnPaint().
Hans Dietrich - 2 Apr '11 - 6:38 View
Maybe he's going for the market in engineering books written in SMS-speak?
Hans Dietrich - 31 Mar '11 - 22:47 View
Which is clearly not happening here. In general, to allow for moving the app, etc., it's safest to specify full paths, preferably ones that the user can modify
Hans Dietrich - 28 Mar '11 - 21:25 View
Correct. #3 is the one I usually use. My 5.
Hans Dietrich - 27 Mar '11 - 0:36 View
Despite your reference to hoe (which has a particular connotation here in LA :) ), your answer is exactly right. My 5.
Hans Dietrich - 26 Mar '11 - 19:25 View
Thanks for the discussion. It sounds like you keep up with this stuff. Why don't you write an article that discusses possible future post-Windows OS's?
Hans Dietrich - 26 Mar '11 - 15:22 View
That looks interesting. Why don't you write an article about how to use Libharu?
Hans Dietrich - 26 Mar '11 - 15:16 View
It will be interesting to see the migration path for current applications to the post-Windows OS (for brevity I will simply refer to this as POS). Microsoft has to walk a fine line here; if they piss off too many app vendors, the vendors will simply switch to Linux. I have already had several clients talk to me about switching to Qt, because they don't trust Microsoft's plans for the POS. A few years ago, I would have said that not even Microsoft is that stupid; now, I think Ballmer has proven to everyone that he is in fact even stupider. So it will be interesting. Fortunately, I've done a lot of Unix work, so what happens with the POS doesn't matter to me.
Hans Dietrich - 21 Mar '11 - 21:26 View
OK, if that's your reason, maybe you should stick to BASIC.
Hans Dietrich - 19 Mar '11 - 5:27 View
You might be right about that. I don't have a better answer. Maybe Chris would consider a temporary jobs forum until the worst of the recession is past. I mean, it wouldn't be taking money away from CodeProject, since the jobs board is defunct.
Hans Dietrich - 19 Mar '11 - 5:07 View
Yes, I agree. It's too bad there isn't a regular forum for posting job ads. On Usenet, people post jobs all the time in C++ forums, etc., so it makes sense to post job in this forum, where C++ programmers may see it.
Hans Dietrich - 19 Mar '11 - 4:58 View
Sandeep, If there was still a jobs board here, I would agree with you 100%. I'm sure you've seen posts about people losing their jobs, and I think there are many others who haven't posted who are also looking for work. During this recession, I think we should relax the rules, in order to help members of this community.
Hans Dietrich - 15 Mar '11 - 19:30 View
aka header guard. :)
Hans Dietrich - 14 Mar '11 - 5:02 View
I was thinking, Why would someone want to do this? I suspect your #2 point is correct.
Hans Dietrich - 13 Mar '11 - 17:11 View
Thank you, Espen. What you said is exactly right. My 5.
Hans Dietrich - 11 Mar '11 - 13:25 View
Reason for my vote of 5 Thanks for updating this.
Hans Dietrich - 8 Mar '11 - 8:10 View
Is 0 a success code or a failure code? In any case, look at the Qt documentation and check why the API could fail.
Hans Dietrich - 7 Mar '11 - 22:22 View
Wow. That really stands out, doesn't it?
Hans Dietrich - 28 Feb '11 - 5:17 View
Show us your code.
Hans Dietrich - 27 Feb '11 - 3:39 View
Note that MSDN says: "For some common controls, the default WM_PAINT message processing checks the wParam parameter. If wParam is non-NULL, the control assumes that the value is an HDC and paints using that device context." The standard way to do this is by using code like this: case WM_PAINT: PAINTSTRUCT ps; HDC hdc = (wParam != NULL) ? (HDC) wParam : ::BeginPaint(hWnd, &ps); if (hdc == 0) return 0; [ do some drawing here] if (wParam == NULL) ::EndPaint(hWnd, &ps); return 0;
Hans Dietrich - 25 Feb '11 - 4:11 View
This looks like you have forgotten to include the module "Seque" in the compile.
Hans Dietrich - 25 Feb '11 - 4:10 View
This looks like you have forgotten to include the module "Seque" in the compile.
Hans Dietrich - 24 Feb '11 - 23:05 View
You're probably getting downvoted because you posted a VB question in the C++ forum. Choose the Visual Basic forum next time. :)
Hans Dietrich - 24 Feb '11 - 4:22 View
In case you're wondering, the C++ purists in this forum are probably annoyed at seeing an MFC question, and so downvoted your question. Next time, post MFC questions in the C++/MFC forum. :)
Hans Dietrich - 21 Feb '11 - 13:14 View
Unless you're dealing with a tightly-controlled in-house app, this is almost always a bad idea. Also bad is putting DLLs in system32. Application DLLs should be put in the app's directory. If you pollute the system path or system32 with non-system DLLs, you could easily end up with a destabilized system with random app crashes. Don't do it. Microsoft says not to.
Hans Dietrich - 21 Feb '11 - 13:07 View
Wow. Just learned something new. Thanks for this answer. Fived.
Hans Dietrich - 20 Feb '11 - 13:17 View
Totally agree about Lippman. Only wish Stroustrup would adopt his style.
Hans Dietrich - 18 Feb '11 - 13:40 View
I considered GDI's performance for .5 seconds before answering, then I figured the OP would like to have something that actually works in the general case. :) If you're really keen on this, why not dash off an article comparing relative performance (GDI vs. ?) for image resize? I would love to read that. There are many algos floating around for doing this, but most simply don't work (at least on the images I've tried). StretchBlt() always works. Seriously, if you know this stuff, please write an article.
Hans Dietrich - 18 Feb '11 - 12:51 View
Reason for my vote of 5 Sweet.
Hans Dietrich - 16 Feb '11 - 10:19 View
Actually, all you need to do is have a boilerplate answer handy, like "See this page on MSDN." Submit that, and then immediately edit it to fill in details. That way, yours will be #1 answer. :)
Hans Dietrich - 12 Feb '11 - 12:58 View
Andrew! Wow. That's almost an article right there.
Hans Dietrich - 7 Feb '11 - 4:58 View
This looks interesting. Maybe you could add a bit more description? What features do you find most valuable?
Hans Dietrich - 4 Feb '11 - 8:39 View
Every occurrence of '\' in a string literal must be doubled: '\\', like 'C:\\Users...".
Hans Dietrich - 3 Feb '11 - 5:45 View
The OP asked about a dll that "exports a number of functions". No mention of classes, etc. I think it's important to address questions that are asked, and not add unnecessary detail; questioners are often beginners and just get confused. I realize that you're very experienced and add extra details gained from that experience. My suggestion: write a tip to record your knowledge.
Hans Dietrich - 31 Jan '11 - 11:05 View
Good answer. (Don't understand the 1-vote.) I would add that if this situation is likely to occur again, then maybe there should be a 'size' member in the struct.
Hans Dietrich - 27 Jan '11 - 11:24 View
Nish, you've got it wrong. He is obviously a CIA troll, looking for people who can read his mind. Anyone giving the appropriate response will be whisked away to a secret CIA lab for more testing and possible use as remote viewers.
Hans Dietrich - 24 Jan '11 - 9:34 View
The version info for my mt.exe in v6.0a\Bin: Version 5.2.3790.2075 Size: 719KB (there is a different mt.exe for x64)
Hans Dietrich - 24 Jan '11 - 9:17 View
Wow. .NET 4.0 wasn't around when VS2008 was released. Are you sure you're using the right mt.exe? What does the version resource say?
Hans Dietrich - 23 Jan '11 - 21:33 View
Maybe the OP has no choice? If he works for a company that uses MFC for internal apps? Probably many other reasons, too.
Hans Dietrich - 5 Jul '10 - 18:10 View
Are you compiling for MBCS or UNICODE? If you are compiling for MBCS, there is code in stdafx.h (#ifdef _UNICODE) that will prevent the manifest from being activated. Just comment out that line and its #endif.
Hans Dietrich - 21 Jun '10 - 16:26 View
It's not necessary for the radio buttons to be in a group box. It IS necessary that the first radio button have the WS_GROUP style, and for all the radio buttons to have the BS_AUTORADIOBUTTON style.
Hans Dietrich - 21 Jun '10 - 16:12 View
Cute but patronizing. If you don't have an answer, it's best to pass on by. If you really have to tell him to google, then say it, without the cute stuff.
Hans Dietrich - 16 Jun '10 - 0:37 View
Thanks for sharing the solution.
Hans Dietrich - 16 Jun '10 - 0:33 View
Geez. The only answer with code and you got 3'd.

Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 1 Jan 1900
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid