Help with RichEdit Window

This is a discussion on Help with RichEdit Window within the C Programming forums, part of the General Programming Boards category; I am creating a program in C that should allow a richedit window to be created and shown. To do ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    5

    Question Help with RichEdit Window

    I am creating a program in C that should allow a richedit window to be created and shown.

    To do this, I have a function.

    Code:
    HWND richedit_creater(double h,double w,HWND hwnd,PCHAR text)
    {
             HANDLE r_lib = LoadLibrary("RICHED32.DLL");
            
            HWND r_hwnd = CreateWindowEx(WS_CHILD,RICHEDIT_CLASS,
            text,1,0,0,(int)h,(int)w,hwnd,(HMENU)0,
          (HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE),
            NULL);
          return r_hwnd;
           
    }
    It compiles fine, and I get no errors. But when I run it, even when simply calling it from a console-app main(), it runs but the window does not does not ever appear. I have tried ShowWindow, GetLastError returns 0...
    I'm a bit confused.

    Could anyone help?
    Thanks,
    -The_Goat();

  2. #2
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Quote Originally Posted by The_Goat()
    Code:
    HWND richedit_creater(double h,double w,HWND hwnd,PCHAR text)
    {
             HANDLE r_lib = LoadLibrary("RICHED32.DLL");
            
            HWND r_hwnd = CreateWindowEx(WS_CHILD,RICHEDIT_CLASS,
            text,1,0,0,(int)h,(int)w,hwnd,(HMENU)0,
          (HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE),
            NULL);
          return r_hwnd;
           
    }
    Several errors. Mainly you should look up CreateWindowEx.

    First argument to CreateWindowEx is dwExStyle, Extended Style. WS_CHILD isn't valid. Valid styles start with WS_EX_.
    Fourth argument is dwStyle. You passed 1. (What is 1?) That should be an OR'd value of styles: things that start with WS_. You'll probably want to pass WS_CHILD and WS_VISIBLE, along with any RICHEDIT specific ones.
    Arguments 7 & 8 are ints. You're casting a double to an int - bad. Don't cast, and it should convert them properly for you. But why are you using doubles? Width and height cannot have a decimal... they describe pixels.

    Otherwise, do you get a valid handle back? CreateWindowEx will return NULL on failure.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  2. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 10:06 AM
  3. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 10:17 AM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 09:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21