Results 1 to 5 of 5

Thread: 4 Easy questions from a beginner to help add to your Post Count

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516

    Wink

    Thank you.

    I'm giving examples of how you would do the same thing in VB to make the questions clearer.

    1) How do I append a Null to a string? (VB: 'strX & vbNull')
    2) How do I generate a random number? (VB: 'Rnd')
    3) How do I redraw evrything on the form automatically (you know without having to put everything in WM_PAINT (Do I set CS_SAVEBITS to the WNDCLASSEX thing to pass to RegisterClassEx or is ther a better way)? (VB: 'Me.Autoredraw = True')
    4) Is there a way to create a static variable (local to a function)? (VB: 'Static MyVar As Long')

    Sorry for my complete ignorance (I started C++ a few days ago). I know I'm ambitious, but the more I'm told, the more I learn.

    Thank you all. But not you in particular.

    Courgettes.

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    1. Strings are by default null-terminated in C++. For example, these do pretty much the same thing. They are different, though, in a very complicated, low-level way.
    Code:
    char* mystring = "My Str";
    char mystring[] = {'M', 'y', ' ', 'S', 't', 'r', '\0');
    2. I think there's a rand() function defined in stdlib.h

    3. I don't know.

    4. Just use static:
    Code:
    void myfunc(int iNum) {
        static int myInt;
        myInt += iNum;
    }
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    Guest
    Use the RedrawWindow or UpdateWindow function.
    Also, keep in mind that redrawing is painting it.

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    I think that for the AutoRedraw stuff, VB itself stores the bitmap and blits that back again, rather than anything in the API.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    Originally posted by parksie
    I think that for the AutoRedraw stuff, VB itself stores the bitmap and blits that back again, rather than anything in the API.
    That's what CS_SAVEBITS does (saves a bitmap and then puts it back)

    Thank you, bozos, you've helped a lot. You'll see. One day I'll be able to do something without having to look through MSDN, and then post a quetion here if I can't find it there.

    Originally posted by, well, me
    One day
    multos grazias
    Courgettes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width