Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

C programming  win32 api RichEdit control problem

Posted on 2003-10-29
14
Medium Priority
?
1,066 Views
Last Modified: 2008-02-26
Hello I am haveing a problem creating a richedit control.I load the riched.dll  in the window main like so......


   if(!LoadLibrary("riched32.dll")){
        MessageBox(hwnd, "Could not load Riched32.dll", "Error", MB_OK | MB_ICONERROR);
     }



then I create my window in the WM_CREATE like so ......


  hEditBox = CreateWindowEx(WS_EX_CLIENTEDGE, "RICHEDIT", "",WS_CHILD | WS_VISIBLE|ES_MULTILINE | WS_VSCROLL | ES_AUTOVSCROLL,
                    0, 0, 100, 100,     hwnd, (HMENU)IDC_MAIN_EDIT, GetModuleHandle(NULL), NULL);

                  if(hEditBox == NULL)
                              MessageBox(hwnd, "Could not create hEditBox.", "Error", MB_OK | MB_ICONERROR);


Everything compiles just fine but when I go and  run it my MessageBox  prompts me it could not create the hEditBox control.I am using windows 98 sec.Can anyone  help me out and maybe tell me what I am doing wrong.If anyone needs any more information please let me know.Also I have tried to load the riched20.dll for 2.0 and use RICHEDIT_CLASS with no luck.

Thank you for your time and help
0
Comment
Question by:bizbiz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
14 Comments
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 9645241

When the CreateWindow() call fails, check the value of GetLastError().  It should have enough information to isolate the problem.


Kent
0
 

Author Comment

by:bizbiz
ID: 9645844

Hello and thank you for your reply, Kent.
The Error code I get back is this


 
The operation completed successfully

This is my Error checking code

      if(hEditBox == NULL)
                    err = GetLastError();
                         FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |FORMAT_MESSAGE_FROM_SYSTEM,NULL,err,0,(LPTSTR)&result,0,NULL);
                                                                                MessageBox(hwnd, result, "Error", MB_OK | MB_ICONERROR);

What would be causeing this error and stop the edit control from working.

Thank you for any help you can give me on this.


0
 
LVL 6

Expert Comment

by:Ajar
ID: 9647945
Hey I think you should not   load  "riched32.dll"   but instead only  "riched32"

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 46

Expert Comment

by:Kent Olsen
ID: 9649817

I trust that your code really looks like:

      if(hEditBox == NULL)
      {
              err = GetLastError();
              FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |FORMAT_MESSAGE_FROM_SYSTEM,NULL,err,0,(LPTSTR)&result,0,NULL);
              MessageBox(hwnd, result, "Error", MB_OK | MB_ICONERROR);
       }

In this case it shouldn't matter, but it may start to give a false error message box once the problem is resolved.


Does the LoadLibrary() call register all of the classes within the library?  "RICHEDIT" is not one of the "standard" classes so it must be registered to Windows with RegisterClass() or RegisterClassEx().

I'm not familiar enough with LoadLibrary() to know if it also does all of the required class registration.

Kent
0
 

Author Comment

by:bizbiz
ID: 9651768
Following the instructions here
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/richedit/richeditcontrols/aboutricheditcontrols.asp



it does not say I have to register the class.I tryed to register the class But its like the class is not there.
That is if the class is Called RICHEDIT in the Riched32.dll.I also tryed the riched20.dll with RICHEDIT_ClASS.The RICHEDIT_CLASS is define in my riched.h file.But it stilll does the same.
0
 

Author Comment

by:bizbiz
ID: 9651794
I am clueless here.Someone throw me a bone hehehe or something.Thank you for your reply Kent.
0
 

Author Comment

by:bizbiz
ID: 9652038
I would think RICHEDIT_CLASS etc would be the  lpszClassName name not the WNDCLASSEX class its self. So what would I register if I had to register the class????
0
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 9652117

The page:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/using_run_time_dynamic_linking.asp

describes one way of dynamic linking.  After the LoadLibrary() call, call GetProcAddress() to see if the API is present.

Kent
0
 

Author Comment

by:bizbiz
ID: 9652591
Ok the......

LoadLibrary("Riched32") or  LoadLibrary("riched20")  is  not equal to NULL.But the.....

GetProcAddress() is equal  to NULL.....So this mean I don't have the api huh :-( ????
 
What to do  now.Thank you once again Kent for your reply/help.

0
 

Author Comment

by:bizbiz
ID: 9654548
Thank you for your reply as well Ajar  
0
 

Author Comment

by:bizbiz
ID: 9657945
Ok I tryed a diffrent way and its stilll doing the same thing i used my dlltool and produced a librich20.a file and I linked it  but it stilll does the same thing and I used RICHEDIT_CLASS . Anyone got any ideas???? What could be going on.Is there anything speacial I have to do with the InitCommonControls(); by chance????.

Thank you for your time.
0
 

Author Comment

by:bizbiz
ID: 9683478
No one has answered this question.Can I have the points back???
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 10446205
PAQed, with points refunded (170)

Computer101
E-E Admin
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question