May 01, 2024, 04:44:28 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Problem resizing my richedit

Started by ExMember001, June 10, 2007, 09:12:29 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ExMember001

I'm trying to resize my richedit control m_Red in this code but when i uncomment the resizing part for the Richedit
the program crash...

popotte.inc

class PopotteMain:CWINDOW
{
declare virtual OnClose(),INT;
declare virtual OnCreate(),INT;
declare virtual OnEraseBkgnd(),INT;
declare virtual OnSize(INT nType,INT cx,INT cy),INT;

declare OpenMainWin();
declare CreateToolBar();
declare CreateMenu();

CICON ico;
CRICHEDIT *m_Red;
CTOOLBAR m_tool;
CMENU m;

RECT rc;

INT L_check;
    INT R_check;
    INT Url_check;
}


popotte.src

////////////////////////////////////////////////////////////////////////////////
// Popotte v3.0 codÃÆ'Ã,© par Krypt compilÃÆ'Ã,© Aurora v1.0 (RC1)
// Copyright ÂÃ,© 2003/2007 par Kryptik CrÃÆ'Ã,©ations, Tout droits rÃÆ'Ã,©servÃÆ'Ã,©s.
////////////////////////////////////////////////////////////////////////////////

#include "Popotte.inc"

#define Titre "Popotte v3.0";

enum PopotteMainControlID
{
RICHEDIT
}

PopotteMain::OpenMainWin()
{
//CrÃÆ'Ã,©ÃÆ'Ã,© la Window Principal du programme
Create(0,0,800,600,AWS_CENTERED|AWS_VISIBLE|AWS_SYSMENU|AWS_SIZE|AWS_MINIMIZEBOX|AWS_MAXIMIZEBOX|AWS_AUTODRAW ,0,Titre,0);
//load caption icon
ico.LoadFromFile(getstartpath()+"images\\Popotte.ico");
seticon(ico.Detach());

//add richedit control
m_Red = new(CRichEdit,1);
m_Red->Create(10,70,771,464,0x50B01044,RICHEDIT,"",this);

setwindowcolor(RGB(200,200,255));
return;
}

////////////////////////////////////////////////////////////////////////////////
//Fenetre Principal Initiation
PopotteMain::OnCreate(),INT
{
CreateMenu();
CreateToolBar();
//CheckWindowsVersion();
return true;
}

////////////////////////////////////////////////////////////////////////////////
//Fenetre Pricipal Ferme
PopotteMain::OnClose(),INT
{
Destroy();
return false;
}

////////////////////////////////////////////////////////////////////////////////
// Controle le Sizing de la fenetre principal
PopotteMain::OnSize(INT nType,INT cx,INT cy),INT
{
//if m_Red->m_hwnd
      //m_Red->SetSize(10,70,cx-22,cy-81);

//resize the toolbar
m_tool.Resize();

return true;
}

PopotteMain::CreateToolBar()
{
    //create the toolbar and set the button tooltips
INT tbarray[12];
tbarray = 2,3,4,5,0,6,0,7,8,9,0,10;
m_tool.LoadFromFile(GetStartPath()+"Images\\Toolbar.bmp",tbarray,12,ACCS_TOP|ATBSTYLE_TRANSPARENT|ATBSTYLE_FLAT|ATBSTYLE_TOOLTIPS,999,this);
m_tool.SetLabels("Livres|Nouvelle|Ouvrir|Sauver|Image|Couper|Copier|Coller|Imprimer||");
m_tool.SetToolTip(2,"Ouvrir Mes Livres de Recettes");
m_tool.SetToolTip(3,"CrÃÆ'Ã,©er une Nouvelle Recette");
m_tool.SetToolTip(4,"Ouvrir Un Fichier");
m_tool.SetToolTip(5,"Sauvegarder votre Recette");
m_tool.SetToolTip(6,"InsÃÆ'Ã,©rer Une Image");
m_tool.SetToolTip(7,"Couper le texte SÃÆ'Ã,©lectionnÃÆ'Ã,© dans le Presse-Papier");
m_tool.SetToolTip(8,"Copier le texte SÃÆ'Ã,©lectionnÃÆ'Ã,© dans le Presse-Papier");
m_tool.SetToolTip(9,"Coller le texte SÃÆ'Ã,©lectionnÃÆ'Ã,© dans le Presse-Papier");
m_tool.SetToolTip(10,"Imprimer la Recette");
m_tool.Resize();
return;
}

PopotteMain::CreateMenu()
{
//CrÃÆ'Ã,©ÃÆ'Ã,© le menu principal
m.BeginMenu();
m.MenuTitle( "&Fichier");
m.MenuItem( "Nouvelle Recette",0,1);
m.MenuItem( "Mes Livres de Recettes",0,2);
m.Separator();
m.MenuItem( "Ouvrir un Fichier",0,3);
m.MenuItem( "Sauvegarder sous...",0,4);
m.Separator();
m.MenuItem( "Imprimer",0,5);
m.Separator();
m.MenuItem( "Sauvegarder",0,6);
m.Separator();
m.MenuItem( "Quitter",0,7);
m.MenuTitle( "&ÃÆ'ââ,¬Â°diter");
m.MenuItem( "Annuler                               Ctrl+Z",0,8);
m.Separator();
m.MenuItem( "Tout SÃÆ'Ã,©lectionner               Ctrl+A",0,9);
m.Separator();
m.MenuItem( "Rechercher",0,10);
m.MenuItem( "Rechercher / Remplacer",0,30);
m.Separator();
m.MenuItem( "InsÃÆ'Ã,©rer une Image",0,38);
m.Separator();
m.MenuItem( "Couper                               Ctrl+X",0,11);
m.MenuItem( "Copier                                Ctrl+C",0,12);
m.MenuItem( "Coller                                 Ctrl+V",0,13);
m.MenuTitle( "&Options");
m.MenuItem( "Changer la Couleur de la FenÃÆ'Ã,ªtre",0,14);
m.MenuItem( "Changer la Couleur de la Barre d'Outils",0,15);
m.Separator();
m.MenuItem( "Ouvrir Mes Livres au DÃÆ'Ã,©marrage",AMF_CHECKED,16);
m.MenuItem( "Ouvrir la DerniÃÆ'Ã,¨re Recette au DÃÆ'Ã,©marrage",AMF_CHECKED,17);
m.Separator();
m.MenuItem( "DÃÆ'Ã,©tection Automatique des Hyperliens",AMF_CHECKED,18);
m.MenuItem( "Lire Seulement",AMF_CHECKED,39);
m.MenuTitle( "&Outils");
m.BeginPopup( "InsÃÆ'Ã,©rer la Date");
m.MenuItem( "MM-JJ-AAAA",0,19);
m.MenuItem( "JJ-MM-AAAA",0,20);
m.MenuItem( "Date Longue",0,21);
m.EndPopup();
m.Separator();
m.MenuItem( "Table des CaractÃÆ'Ã,¨res",0,22);
m.Separator();
m.MenuItem( "Orthographe",0,34);
m.MenuItem( "Conjuguer",0,33);
m.MenuItem( "Rechercher Synonymes",0,32);
m.MenuItem( "Rechercher sur WikipÃÆ'Ã,©dia",0,31);
m.Separator();
m.MenuItem( "Convertisseur",0,29);
m.Separator();
m.MenuItem( "Ouvrir le RÃÆ'Ã,©pertoire Recettes",0,40);
m.MenuTitle( "&Format");
m.MenuItem( "&Police par default",0,27);
m.Separator();
m.MenuItem( "&Marges",0,28);
m.Separator();
m.MenuItem( "Normal",0,37);
m.MenuItem( "SubScript",0,35);
m.MenuItem( "SuperScript",0,36);
m.MenuTitle( "&Aide");
m.MenuItem( "Truc du Jour",0,23);
m.Separator();
m.MenuItem( "Aide",0,24);
m.Separator();
m.MenuItem( "Kryptik CrÃÆ'Ã,©ations",0,25);
m.MenuItem( "Mise ÃÆ'Ã,  jour",0,41);
m.Separator();
m.MenuItem( "ÃÆ'€ Propos",0,26);
    m.EndMenu();
SetMenu(m.Detach());

// Uncheck MenuItem at start
    L_check =   0;
    R_check =   0;
    Url_check = 0;

return true;
}

PopotteMain::OnEraseBkgnd(),INT
{
//simple example of skinning the toolbar with a color.
rc = m_tool.GetWindowRect();
    DrawRect(0,0,rc.right-rc.left+1,rc.bottom-rc.top,RGB(200,200,255),RGB(200,200,255));
return true;
}

////////////////////////////////////////////////////////////////////////////////
// Main Subroutine
global sub main()
{
PopotteMain Popotte;
Popotte.OpenMainWin();
do {wait();} until !Popotte.IsValid();
delete Popotte.m_Red;
return;
}


anyone can point me why the crash occur? please.

Ionic Wind Support Team

Sure.  Add a constructor to your class:


class PopotteMain:CWINDOW
{
      declare PopotteMain();
...//the rest of your class
}

PopotteMain::PopotteMain()
{
    m_Red = NULL;
}

And in your OnSize handler check to make sure the control exists.


PopotteMain::OnSize(INT nType,INT cx,INT cy),INT
{
if m_Red
            m_Red->SetSize(10,70,cx-22,cy-81);

//resize the toolbar
m_tool.Resize();

return true;
}


Windows fires off OnSize events as soon as the window is created, long before you are creating the RichEdit control.  Which is why we use constructors to set pointers to NULL.  That's what a constructor is for.

Paul.
Ionic Wind Support Team

ExMember001


pistol350

Hi Krypt!
Nice to see that you are porting your Popotte program to Aurora  ;)
Regards,

Peter B.

ExMember001

June 11, 2007, 08:47:24 PM #4 Last Edit: June 11, 2007, 09:58:16 PM by KrYpT
yep, lost parts of my previous code unfortunally....  :-\