Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
S

Steen Krogsgaard

@Steen Krogsgaard
About
Posts
313
Topics
7
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Getting user input into a list control
    S Steen Krogsgaard

    Instead of using a list control, use a list-view control with LVS_EDITLABELS style set. See MSDN List-view control or LVS_EDITLABELS for details.

    Cheers Steen. "Are you gonna check your makeup when you're done whining?" John Simmons, 05/31/2006 "Of course, the next day it automatically updates, and your quick'n'dirty patches cause the new binaries to segfault all over your linoleum. If only you'd had the source..." Shog, 10/18/2006 "One day I realized that sadness is just another word for not enough coffee" Wally, 10/18/2006

    C / C++ / MFC java question

  • how can I get the integer value of INSERT from keyboard??
    S Steen Krogsgaard

    I have never worked with IE plugins, so I can't help you there.

    Cheers Steen. "Are you gonna check your makeup when you're done whining?" John Simmons, 05/31/2006 "Of course, the next day it automatically updates, and your quick'n'dirty patches cause the new binaries to segfault all over your linoleum. If only you'd had the source..." Shog, 10/18/2006 "One day I realized that sadness is just another word for not enough coffee" Wally, 10/18/2006

    C / C++ / MFC question windows-admin

  • how can I get the integer value of INSERT from keyboard??
    S Steen Krogsgaard

    VK_INSERT, VK_PRIOR, VK_NEXT, VK_END, VK_HOME. Defined in Windows.h Also, look in MSDN. But why do you want to register system-wide hotkeys?

    Cheers Steen. "Are you gonna check your makeup when you're done whining?" John Simmons, 05/31/2006 "Of course, the next day it automatically updates, and your quick'n'dirty patches cause the new binaries to segfault all over your linoleum. If only you'd had the source..." Shog, 10/18/2006 "One day I realized that sadness is just another word for not enough coffee" Wally, 10/18/2006

    C / C++ / MFC question windows-admin

  • about const member function
    S Steen Krogsgaard

    _text is a char*. The const member promises not to change any of the member variables. Your first assignment changes _text to point to a different string. The second assignment (in the loop) does not change _text, but the content of the string that _text points to (btw, I assume that _text has been assigned to a valid string at some point in code not shown, otherwise the second assignment will corrupt your memory). const pointers can point to mutable objects. You may change content of the object, but not the content of the pointer.

    Cheers Steen. "Are you gonna check your makeup when you're done whining?" John Simmons, 05/31/2006 "Of course, the next day it automatically updates, and your quick'n'dirty patches cause the new binaries to segfault all over your linoleum. If only you'd had the source..." Shog, 10/18/2006 "One day I realized that sadness is just another word for not enough coffee" Wally, 10/18/2006

    C / C++ / MFC help tutorial question

  • RegisterClass
    S Steen Krogsgaard

    Well, even if there only exist one window of any given class in the entire universe, Windows still needs to know these things. And since there may exists hundreds of windows of the same class (a static text control is a good example) you may as well put these common things into a windows class instead of defining them for each instance of the class. It's analogous to defining the member functions of a C++ class each time you declare an instance - that would not be efficient either. The bottom line is that your Windows program won't work if you don't register your window classes. Live with it. :)

    Cheers Steen. "Are you gonna check your makeup when you're done whining?" John Simmons, 05/31/2006

    C / C++ / MFC question

  • RegisterClass
    S Steen Krogsgaard

    The windows class has a lot of functionality. The most important is to tell Windows which WndProc to call when a message is send to the window. It also tells which brush to use to paint the background, which icon to show and which cursor should be displayed when the mouse is over the window. It also tells Windows which menu to associate with the window. Pretty important stuff.

    Cheers Steen. "Are you gonna check your makeup when you're done whining?" John Simmons, 05/31/2006

    C / C++ / MFC question

  • Missing '=' in if-statement
    S Steen Krogsgaard

    I guess it's different between C/C++ and java. I will check it in C/C++ (just for the sake of completeness :)) tonight. Untill then, we agree that i = 2 is an assignment, but I'm pretty sure that in C++ this will evaluate to the right-most element, i.e. 2. And 2 is a true value in C/C++. The evaluate-to-rightmost rule also works here: int i = j = 2; here 2 is assigned to j, and the result of this assignment (i.e. 2) is assigned to i. Anyway, thanks for the discussion!

    Cheers Steen. "Are you gonna check your makeup when you're done whining?" John Simmons, 05/31/2006

    Clever Code learning

  • Missing '=' in if-statement
    S Steen Krogsgaard

    I understand your point, but I still think you are wrong (at least in C/C++) if (myBool = false) { // this line will never ever be executed, as the statement evaluates to false } if (i = 2) { // this line will always be executed, because the statement will evaluate to 2, which is non-zero and thus true. } if (i = 0) { // this line will not be executed, the statement evaluates to 0 => false } (disclaimer: I'm not on my devel PC right now, so this is from memory. But I'm pretty sure...)

    Cheers Steen. "Are you gonna check your makeup when you're done whining?" John Simmons, 05/31/2006

    Clever Code learning

  • Not strictly a bug, but it caught me by surprise
    S Steen Krogsgaard

    VC++ does *not* assign any value by default in release builds. Here the value of i will be random. In debug builds all variables are initalized to their zero element (0 in the case of ints, NULL in the case of pointers).

    Cheers Steen. "Are you gonna check your makeup when you're done whining?" John Simmons, 05/31/2006

    Clever Code csharp c++ java delphi help

  • Missing '=' in if-statement
    S Steen Krogsgaard

    Oh no. At least in C/C++ the result of the assignment is the right-most value, i.e. false. Similarly, if (i=2) {... evaluates to 2.

    Cheers Steen. "Are you gonna check your makeup when you're done whining?" John Simmons, 05/31/2006

    Clever Code learning

  • Interesting passages from the Jew's holy book
    S Steen Krogsgaard

    wiki on speciation[^] In addition, all humans are the same species, Homo sapiens. For a while, we thought there was evidence of another species of humans living about 13000 years ago on a small island in Indonesia (Homo floresiensis[^]), but this turned out to be "just" a pygmee (published in Proceedings of the National Academy of Sciences, USA, vol 103, issue 36). As others have said, races do not have a biological meaning. Instead, you talk about variants or strains of a specific species. So, the "races" of dogs, for instance, all belong to the same species (Canis lupus; this species also includes wolves (yes, they are the same species as dogs!). However, dogs are commonly separated into their own sub-species, Canis lupus familiaris, sometimes referred to as Canis familiaris as if they were a species of their own). A somewhat simplistic definition of species is that if two individuals (of opposite sex, apparently) can have fertile offspring they belong to the same species. This is exemplified by mules, which arise as sterile offspring of a horse and an ass (or is the right name a donkey?). Horses and asses are different species, so the mule is a sterile hybrid. Back to the original question: You cannot separate humans into different species or even subspecies, we're all Homo sapiens, no matter what the rednecks say. And separation into races is artificial and just the result of mankinds everlasting need to put everything into neat little boxes that can be overly simplistic labelled.

    Cheers Steen. "Are you gonna check your makeup when you're done whining?" John Simmons, 05/31/2006

    The Back Room learning

  • Finding deleted virtual keywords
    S Steen Krogsgaard

    What do you mean by "has been deleted" - did the editor delete it or what? Anyway, it really doesn't matter. If a method is declared virtual in a base class it is implicitly virtual in a derived class even if it is not declared as such in the derived class. This makes sense as the entry in the vtable is already there (from the base class declaration), no need to declare it again. But I still don't understand how it got deleted...

    Cheers Steen. "Are you gonna check your makeup when you're done whining?" John Simmons, 05/31/2006

    C / C++ / MFC question

  • Linking Error / outportb [modified]
    S Steen Krogsgaard

    %d format specifier is signed decimal integer. For your double, use %f. For your unsigned ints, use %u -- modified at 8:35 Thursday 17th August, 2006 Well, actually, since you have chars in your union you should use %c instead of %u.

    Cheers Steen. "Are you gonna check your makeup when you're done whining?" John Simmons, 05/31/2006

    C / C++ / MFC help question

  • client of a class
    S Steen Krogsgaard

    In what context? Perhaps it's a system that lawyers use to grade their clients - working class clients, upper class clients, royal clients? :-D

    Cheers Steen. "Are you gonna check your makeup when you're done whining?" John Simmons, 05/31/2006

    C / C++ / MFC question

  • How to declare WindowProc function in class
    S Steen Krogsgaard

    (Disclaimer: This is for VC++6.0 and for MFC, and I'm pretty sure that this is not exactly what you use. Anyway, it may give you some ideas.) (Disclaimer: Untested code) You have the window handle as a parameter to WndProc, so it's easy to get the MFC C++ class corresponding to the window:

    static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    if (wparam == DBT_DEVICEARRIVAL) {
    CYourWnd* wnd = (CYourWnd*)CWnd::FromHandlePermanent(hWnd);
    if ((wnd != NULL) && (wnd->IsKindOf(RUNTIME_CLASS(CYourWnd))) {
    // access CYourWnd members by wnd->
    }
    }
    }

    More on-beat C++ programmers will probably object to using the old-style typecasts, but it's safe when checking wnd for NULL and checking the runtime class.

    Cheers Steen. "Are you gonna check your makeup when you're done whining?" John Simmons, 05/31/2006

    C / C++ / MFC help tutorial question

  • operator new
    S Steen Krogsgaard

    Honestly, I have no idea why the compiler doesn't support initializing arrays of classes during construction, but according to MSDN that's just the way it is. Perhaps there's some sort of breach of the standard or a problem with the syntax. I don't know. I don't know what's your use of this is, but maybe it will be easier for you to use an array of pointers instead of a pointer to an array. Then you can allocate and initialize each element in a loop instead.

    Cheers Steen. "Are you gonna check your makeup when you're done whining?" John Simmons, 05/31/2006

    C / C++ / MFC question php com data-structures regex

  • Error in reading file
    S Steen Krogsgaard

    Take a look at scanf.

    Cheers Steen. "Are you gonna check your makeup when you're done whining?" John Simmons, 05/31/2006

    C / C++ / MFC question help

  • operator new
    S Steen Krogsgaard

    Right. If you wan't to be politically OOP correct you write accessor functions to your member variables. In this case, with the member being an int, I would just assign directly to it in a loop.

    Cheers Steen. "Are you gonna check your makeup when you're done whining?" John Simmons, 05/31/2006

    C / C++ / MFC question php com data-structures regex

  • Please help
    S Steen Krogsgaard

    Come on Cedric, on CodeProject it should be a perfectly valid request to ask for the source code for a module or class that can do serial communication. In my mind, he doesn't have to try to make it himself before he asks for an "off-the-shelf" class. His question may not be the best worded one, but this goes for many of us non-native-english speakers. I know, and I fully agree, that we see some rather stupid requests here at CP from time to time (the guy with about 60 minutes patience comes to mind). I just don't think this is one of them.

    Cheers Steen. "Are you gonna check your makeup when you're done whining?" John Simmons, 05/31/2006

    C / C++ / MFC help question

  • operator new
    S Steen Krogsgaard

    You have to supply a default constructor. From MSDN: "No explicit per-element initialization can be done when allocating arrays using the new operator; only the default constructor, if present, is called. See Default Arguments for more information" (MSDN[^])

    Cheers Steen. "Are you gonna check your makeup when you're done whining?" John Simmons, 05/31/2006

    C / C++ / MFC question php com data-structures regex
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups