Initialization of the editor in C++

[Top]  [Chapter]  [Previous]  [Next]

Only a few lines of code are required to build a verstile and powerful editor in Visual Studio 2008:

     

Our demo uses this code to initialize the "create" function

 

// Pointer to TextDynamic

fkt_wptextCreateDialog* wptextCreateDialog;

 

 

#define TD_DLL "WPTextDLL01Demo.dll" ***MODIFY NAME***

 

// Load the DLL and get the method pointer

bool InitTD()

{

  static HINSTANCE Engine;

 Engine = LoadLibrary(TEXT(TD_DLL));

 if(Engine==NULL)return false;

   wptextCreateDialog = (fkt_wptextCreateDialog *)GetProcAddress( Engine, "wptextCreateDialog" );  

 if(wptextCreateDialog==NULL)return false;

 else return true;

}

 

 

Later, in

 

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

 

this code is executed:

 

1) Creation of editor    

 

 case WM_CREATE:

         {

                 DefWindowProc(hWnd, message, wParam, lParam);

                 unsigned long editorw; //not used, reserved

                 static TDCreateDialogParam param;

 

                 if(InitTD())

                 {

                         param.size = sizeof(param);

                         param.modes = 1;

                         param.editor_mode = 4; // with thumbnails

                         param.editor_xmode = 255; // all features

                         param.editor_gui1 = 478;

                         param.editor1_layoutmode = 7; // Full Layout

                         param.editor1_autozoom = 1; // Width

 

                         // We can set all "Memo.SetBProp" flags.

                         // Using Group=0, ID=11 (bit 11) we activate Image drag&drop

                         param.Memo1_SetBProp_ADD[0] = (1024 * 2); // Bit 11 -> AcceptFiles

 

                         param.pccfile = "{dll}buttons.pcc";

                         edhwnd = wptextCreateDialog(hWnd, &param, 10, 10, 300, 300, &editorw );

         }

 

2) Sizing of the editor

 

 case WM_SIZE:

         DefWindowProc(hWnd, message, wParam, lParam);

         if(edhwnd)

         {

                 RECT Rect;

                 GetClientRect(hWnd, &Rect);

                 MoveWindow(edhwnd, Rect.left, Rect.top, Rect.right-Rect.left, Rect.bottom-Rect.top, false);

         }

         break;

 

3) Avoid flickering

 

 case WM_ERASEBKGND: //<---

     

         break;

 

Thats All!


[textcontrol_vs2008.htm]    Copyright © 2007 by WPCubed GmbH