Question sur CreateWindowEx

Résolu
cs_Pathfinder Messages postés 2 Date d'inscription samedi 13 septembre 2003 Statut Membre Dernière intervention 10 août 2005 - 10 août 2005 à 15:26
cs_Pathfinder Messages postés 2 Date d'inscription samedi 13 septembre 2003 Statut Membre Dernière intervention 10 août 2005 - 10 août 2005 à 16:39
Bonjour,

J'ai un petit probleme, j'ai dans mon application une zone TEXT, je voudrai le changer par une zone Rich Edit je déclare donc ceci:

#include <commctrl.h>
#include <Richedit.h>

InitCommonControls();

hEdit = CreateWindowEx(0, "RICHEDIT", "", WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_WANTRETURN | WS_VSCROLL,0, 0, 0, 0, hwnd, NULL, hinst, NULL);

Mais sa ne fonctionne pas avec le control RICHEDIT, par contre pas de problemme avec EDIT !!!

J'ai trouvé ceci dans msdn anglais:

Creating a Rich Edit Control

To create a rich edit control, call the CreateWindowExRichEdit</italique> for the window class parameter. If you are using Rich Edit 2.0 or later (Riched20.dll), specify RICHEDIT_CLASS for the window class parameter

Merci. pour votre aide.

LSI

3 réponses

racpp Messages postés 1909 Date d'inscription vendredi 18 juin 2004 Statut Modérateur Dernière intervention 14 novembre 2014 17
10 août 2005 à 15:52
Salut,

Voici un exemple complet:



#include <windows.h>



LRESULT CALLBACK WndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)

{

switch (Message)

{

case WM_DESTROY:

PostQuitMessage(0);

return 0;

default:

return DefWindowProc(hWnd, Message, wParam, lParam);

}

}



int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)

{



WNDCLASSEX wc;

char NomClasse[] = "MaFenetre";

wc.cbSize = sizeof(WNDCLASSEX);

wc.style =0;

wc.lpfnWndProc = WndProc;

wc.cbClsExtra = 0;

wc.cbWndExtra = 0;

wc.hInstance = hInstance;

wc.hIcon = 0;

wc.hCursor = LoadCursor(0, IDC_ARROW);

wc.hbrBackground = (HBRUSH) COLOR_WINDOW;

wc.lpszMenuName = 0;

wc.lpszClassName = NomClasse;

wc.hIconSm = 0;

RegisterClassEx(&wc);

HWND hFenet = CreateWindow( NomClasse, "Création
d'un RichEdit", WS_OVERLAPPEDWINDOW, 0, 0, 640, 480, 0, 0,
hInstance, 0);

HINSTANCE richDll = LoadLibrary("RICHED20.DLL");

HWND hRich= CreateWindow( "RichEdit20A", "Je suis un
RichEdit !", WS_CHILD | WS_VISIBLE | ES_MULTILINE ,
10, 10, 300, 300, hFenet, 0, hInstance, 0);

ShowWindow(hFenet, nCmdShow);

UpdateWindow(hFenet);



MSG msg;

while (GetMessage(&msg, 0, 0, 0))

{

TranslateMessage(&msg);

DispatchMessage(&msg);

}



FreeLibrary(richDll);

return msg.wParam;

}
3
vecchio56 Messages postés 6535 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 22 août 2010 14
10 août 2005 à 15:46
LoadLibrary("Riched20.dll") au debut de ton prog
0
cs_Pathfinder Messages postés 2 Date d'inscription samedi 13 septembre 2003 Statut Membre Dernière intervention 10 août 2005
10 août 2005 à 16:39
Voici mon code modifier :

#include <windows.h>
#include <commctrl.h>


HINSTANCE hinst;


LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);


int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
...
InitCommonControls();
hinst = hinstance;
HINSTANCE richDll = LoadLibrary("RICHED20.DLL");
...
}

LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{

static HWND hEdit;
static HWND hsb;
static BOOL EditNotChg = TRUE;
switch (uMsg)
{
case WM_CREATE:


//Edit RICHTEXT
{
HFONT hFont;
hEdit = CreateWindow( "RichEdit20A", "Je suis un RichEdit !", WS_CHILD | WS_VISIBLE | ES_MULTILINE,10, 10, 300, 300, hwnd, 0, hinst, 0);


hFont = (HFONT)GetStockObject(ANSI_FIXED_FONT);
SendMessage(hEdit,WM_SETFONT,(UINT)hFont,TRUE);
SendMessage(hEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(5, 5));

//DEBUT Init ToolBar
hsb = CreateStatusWindow(WS_CHILD | WS_VISIBLE, "MsgEditeur 2005", hwnd, FALSE);
// FIN Init ToolBar
return 0;
}
Merci racpp sa fonctionne.
0
Rejoignez-nous