Click here to Skip to main content

Comments by Hans Dietrich (Top 123 by date)

Hans Dietrich at 16-Jul-11 18:16pm View
   
Deleted
Reason for my vote of 5
This is such a great idea! Each category should have a Tip like this.
Hans Dietrich at 21-May-11 22:14pm View
   
Yes, and could you double-size me, too?
Hans Dietrich at 20-May-11 19:19pm 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 at 20-May-11 17:54pm View
   
Yes, I think MessageBox will do what he wants, if he chooses the right set of options.
Hans Dietrich at 20-May-11 8:32am View
   
Please take a look at MB_TASKMODAL option of MessageBox().
Hans Dietrich at 20-May-11 8:32am View
   
Deleted
Please take a look at MB_TASKMODAL option of MessageBox().
Hans Dietrich at 17-May-11 4:30am View
   
Good answer.
Hans Dietrich at 16-May-11 4:40am 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 at 14-May-11 18:41pm 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 at 14-May-11 18:36pm View
   
Evil. God will get you for this.
Hans Dietrich at 10-May-11 23:30pm View
   
Agree. Letting the system choose the processor is nearly always the right way. Great links. My 5.
Hans Dietrich at 10-May-11 23:26pm View
   
Accurate, complete answer. My 5.
Hans Dietrich at 10-May-11 20:46pm 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 at 9-May-11 8:49am View
   
Nice link. My 5.
Hans Dietrich at 8-May-11 3:54am 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 at 5-May-11 15:33pm 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 at 5-May-11 5:40am View
   
Good complete answer. My 5.
Hans Dietrich at 4-May-11 0:04am View
   
There are extensions that provide this: http://www.han-soft.com/uninshs.php
Hans Dietrich at 2-May-11 21:31pm View
   
Have you checked with the manufacturer of the projector?
Hans Dietrich at 2-May-11 11:46am View
   
Take another look at your function f. If i is NOT equal to 0, what is returned?
Hans Dietrich at 2-May-11 4:56am View
   
Unless it's a static, like Alain says.
Hans Dietrich at 2-May-11 4:03am 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 at 2-May-11 2:09am 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 at 2-May-11 1:51am View
   
Correct, my 5.
Hans Dietrich at 2-May-11 0:35am View
   
Who cares?
Hans Dietrich at 30-Apr-11 21:26pm View
   
I know you didn't; but from the 1-votes other people obviously thought that.
Hans Dietrich at 30-Apr-11 15:32pm 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 at 30-Apr-11 0:27am 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 at 29-Apr-11 23:50pm 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 at 29-Apr-11 19:21pm 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 at 28-Apr-11 16:57pm 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 at 28-Apr-11 15:26pm 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 at 26-Apr-11 22:45pm View
   
Good answer, my 5.
Hans Dietrich at 26-Apr-11 17:35pm View
   
Yes, exactly.
Hans Dietrich at 26-Apr-11 17:17pm 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 at 26-Apr-11 15:31pm 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 at 26-Apr-11 15:18pm View
   
MUST.NOT.SAY.DOS.BOX!
Hans Dietrich at 26-Apr-11 14:46pm View
   
Good guidance, Nish.
Hans Dietrich at 26-Apr-11 14:26pm View
   
Edited for grammar and SMS speak.
Hans Dietrich at 25-Apr-11 18:53pm View
   
Very true!
Hans Dietrich at 24-Apr-11 18:39pm View
   
Wow. Never heard of it before.
Hans Dietrich at 19-Apr-11 9:39am View
   
Maybe two people in the same class? :)
Hans Dietrich at 19-Apr-11 4:25am View
   
It's actually very well-written and fun to read.
Hans Dietrich at 19-Apr-11 2:52am 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 at 19-Apr-11 2:21am 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 at 19-Apr-11 1:59am 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 at 19-Apr-11 1:52am View
   
Except for the reference to Fred Brooks, an excellent link.
Hans Dietrich at 19-Apr-11 0:22am View
   
Microsoft bought code from BCGSoft and renamed it MFC Feature Pack.
Hans Dietrich at 18-Apr-11 11:40am 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 at 18-Apr-11 10:05am 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 at 18-Apr-11 9:57am 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 at 17-Apr-11 22:48pm View
   
If that's true, then why didn't OP report an error on that line?
Hans Dietrich at 17-Apr-11 12:49pm 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 at 16-Apr-11 0:59am View
   
This is what I was going to say, but you beat me to it. My 5.
Hans Dietrich at 13-Apr-11 20:31pm View
   
I'll bet you a beer the next MS OS will include the VS6 MFC DLLs.
Hans Dietrich at 13-Apr-11 9:24am View
   
Googlé
Hans Dietrich at 13-Apr-11 8:13am View
   
Exactly, which is what I said in my Solution 1.
Hans Dietrich at 13-Apr-11 7:55am View
   
If the message map entry or message handler is missing, it would be passed to default handler, which would close it.
Hans Dietrich at 11-Apr-11 22:19pm 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 at 11-Apr-11 19:04pm View
   
:)
Who knows? He may learn something anyway!
Hans Dietrich at 11-Apr-11 4:15am View
   
OK, no problem.
Hans Dietrich at 11-Apr-11 3:48am View
   
That would depend on the code in the function.
Hans Dietrich at 10-Apr-11 23:27pm View
   
Classic! This one should go to Q&A Hall of Fame.
Hans Dietrich at 10-Apr-11 11:38am View
   
Gave you a 5, one of my favorite tricks.
Hans Dietrich at 10-Apr-11 9:16am View
   
Yes, I use this too. Since it was a newbie question, I wanted to stick to the basics.
Hans Dietrich at 10-Apr-11 9:13am View
   
Brilliant! I now have a new goal in life!
Hans Dietrich at 10-Apr-11 3:53am 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 at 10-Apr-11 1:47am 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 at 10-Apr-11 0:17am 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 at 10-Apr-11 0:16am View
   
Deleted
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 at 7-Apr-11 0:21am View
   
It's sad, pathetic, idiotic. I run out of words to describe.
Hans Dietrich at 6-Apr-11 23:31pm View
   
:) :) :) Personal experience - from staring at a dozens of comboboxes and wondering why the listbox wouldn't drop!
Hans Dietrich at 6-Apr-11 22:09pm View
   
No, SHGetFolderPath works fine on Win7. It's the MS-recommended alternative that does not work prior to Vista.
Hans Dietrich at 6-Apr-11 10:10am View
   
You're welcome!
Hans Dietrich at 6-Apr-11 9:48am 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 at 6-Apr-11 6:48am 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 at 6-Apr-11 2:10am 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 at 5-Apr-11 18:46pm View
   
Correct, my 5.
Hans Dietrich at 2-Apr-11 10:43am 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 at 2-Apr-11 7:05am View
   
Don't you keep a list of the drawing objects? Simply repaint the list in OnPaint().
Hans Dietrich at 2-Apr-11 6:38am View
   
Maybe he's going for the market in engineering books written in SMS-speak?
Hans Dietrich at 31-Mar-11 22:47pm 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 at 28-Mar-11 21:25pm View
   
Correct. #3 is the one I usually use. My 5.
Hans Dietrich at 27-Mar-11 0:36am View
   
Despite your reference to hoe (which has a particular connotation here in LA :) ), your answer is exactly right. My 5.
Hans Dietrich at 26-Mar-11 19:25pm 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 at 26-Mar-11 15:22pm View
   
That looks interesting. Why don't you write an article about how to use Libharu?
Hans Dietrich at 26-Mar-11 15:16pm 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 at 21-Mar-11 21:26pm View
   
Deleted
OK, if that's your reason, maybe you should stick to BASIC.
Hans Dietrich at 19-Mar-11 5:27am 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 at 19-Mar-11 5:07am 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 at 19-Mar-11 4:58am 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 at 15-Mar-11 19:30pm View
   
aka header guard. :)
Hans Dietrich at 14-Mar-11 5:02am View
   
I was thinking, Why would someone want to do this? I suspect your #2 point is correct.
Hans Dietrich at 13-Mar-11 17:11pm View
   
Thank you, Espen. What you said is exactly right. My 5.
Hans Dietrich at 11-Mar-11 13:25pm View
   
Deleted
Reason for my vote of 5
Thanks for updating this.
Hans Dietrich at 8-Mar-11 8:10am 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 at 7-Mar-11 22:22pm View
   
Deleted
Wow. That really stands out, doesn't it?
Hans Dietrich at 28-Feb-11 5:17am View
   
Show us your code.
Hans Dietrich at 27-Feb-11 3:39am 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 at 25-Feb-11 4:11am View
   
This looks like you have forgotten to include the module "Seque" in the compile.
Hans Dietrich at 25-Feb-11 4:10am View
   
Deleted
This looks like you have forgotten to include the module "Seque" in the compile.
Hans Dietrich at 24-Feb-11 23:05pm 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 at 24-Feb-11 4:22am 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 at 21-Feb-11 13:14pm 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 at 21-Feb-11 13:07pm View
   
Wow. Just learned something new. Thanks for this answer. Fived.
Hans Dietrich at 20-Feb-11 13:17pm View
   
Totally agree about Lippman. Only wish Stroustrup would adopt his style.
Hans Dietrich at 18-Feb-11 13:40pm 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 at 18-Feb-11 12:51pm View
   
Deleted
Reason for my vote of 5
Sweet.
Hans Dietrich at 16-Feb-11 10:19am 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 at 12-Feb-11 12:58pm View
   
Andrew! Wow. That's almost an article right there.
Hans Dietrich at 7-Feb-11 4:58am View
   
Deleted
This looks interesting. Maybe you could add a bit more description? What features do you find most valuable?
Hans Dietrich at 4-Feb-11 8:39am View
   
Every occurrence of '\' in a string literal must be doubled: '\\', like 'C:\\Users...".
Hans Dietrich at 3-Feb-11 5:45am 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 at 31-Jan-11 11:05am 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 at 27-Jan-11 11:24am 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 at 24-Jan-11 9:34am 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 at 24-Jan-11 9:17am 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 at 23-Jan-11 21:33pm 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 at 5-Jul-10 18:10pm 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 at 21-Jun-10 16:26pm 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 at 21-Jun-10 16:12pm 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 at 16-Jun-10 0:37am View
   
Thanks for sharing the solution.
Hans Dietrich at 16-Jun-10 0:33am View
   
Geez. The only answer with code and you got 3'd.

Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 1 Jan 1900
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid