Page 2 of 6
Re: EditBox control: increase capacity
Posted: Tue Jul 09, 2013 11:28 pm
by srvet_claudio
Hi all.
The final solution is more simpler than what I said in the previous post.
In source file:
c_windows.c you change the original
GETWINDOWTEXT function for this function:
Code: Select all
HB_FUNC ( GETWINDOWTEXT )
{
int iLen = GetWindowTextLength((HWND) hb_parnl (1));
TCHAR *cText = (TCHAR*) hb_xgrab((iLen+1) * sizeof(TCHAR));
GetWindowText((HWND) hb_parnl (1), (LPTSTR) cText, (iLen+1));
HMG_retc( cText );
hb_xfree( cText );
}
and re-build the library.
EditBox control: increase capacity
Posted: Tue Jul 09, 2013 11:47 pm
by Pablo César
Thank you Dr. Soto ! Working properly.
GETWINDOWTEXT function shorter and better !
I will announce in the other forum your patch for fix and for next releases. Many tks
Re: EditBox control: increase capacity
Posted: Wed Jul 10, 2013 6:52 pm
by Carlos Britos
Hi Claudio
I found a couple of problems in the editbox.
With increasing text size caretPos not return the real value.
The overwrite mode is not working.
Everything seems to be related to EM_GETSEL (32 bit). I don't have it very clear.
I don't know how to increase the limit of EM_GETSEL.
It wasn't tested yet with your last function.
Lamento no poder ayudar
Re: EditBox control: increase capacity
Posted: Thu Jul 11, 2013 1:18 am
by srvet_claudio
Carlos Britos wrote:Hi Claudio
I found a couple of problems in the editbox.
With increasing text size caretPos not return the real value.
The overwrite mode is not working.
Everything seems to be related to EM_GETSEL (32 bit). I don't have it very clear.
I don't know how to increase the limit of EM_GETSEL.
It wasn't tested yet with your last function.
Lamento no poder ayudar
Carlos thanks for reporting this bug.
In source file:
h_controlmisc.prg you change the original
_GetCaretPos function for this function:
Code: Select all
*-----------------------------------------------------------------------------*
Function _GetCaretPos ( ControlName , FormName )
*-----------------------------------------------------------------------------*
Local i, nStart, nEnd
i := GetControlIndex ( ControlName, FormName )
If i == 0
Return 0
EndIf
HMG_SendMessage ( _HMG_SYSDATA [3] [i] , EM_GETSEL, @nStart, @nEnd )
Return nEnd
In source file:
c_windows.c your add this function:
Code: Select all
HB_FUNC (HMG_SENDMESSAGE)
{ HWND hWnd = (HWND) hb_parnl(1);
UINT nMsg = (UINT) hb_parnl(2);
LONG wParam = (LONG) hb_parnl(3);
LONG lParam = (LONG) hb_parnl(4);
LONG lResult;
lResult = (LONG) SendMessage (hWnd, nMsg, (WPARAM) &wParam, (LPARAM) &lParam);
hb_retnl ((LONG) lResult);
if (HB_ISBYREF(3))
hb_stornl ((LONG) wParam, 3);
if (HB_ISBYREF(4))
hb_stornl ((LONG) lParam, 4);
}
Best Regards,
Claudio
EditBox control: increase capacity
Posted: Thu Jul 11, 2013 2:45 am
by Pablo César
Hi Claudio,
changes were made and rebuilded LIB, but
overwrite mode is still not working.

Re: EditBox control: increase capacity
Posted: Thu Jul 11, 2013 2:13 pm
by srvet_claudio
Pablo César wrote:but
overwrite mode is still not working.

Sorry Pablo, but I not understand what you said.
EditBox control: increase capacity
Posted: Thu Jul 11, 2013 2:33 pm
by Pablo César
Me refiero que cuando editamos dentro del EditBox, mismo que presionemos la tecla insert, no difiere el comportamiento entre sobre-escribir um texto ya existe y el modo de insercion de texto. Para que puedas entender mejor Claudio, fijate en este link (ejecutable y fuentes):
How do I introduce insert/overwrite mode in edit control ?
Carlos Britos wrote:The overwrite mode is not working.
Creo que esto nunca funcionó en el EditBox de HMG. Solo vuelvo a exponer lo que Carlos se referia. Seria importante como nueva implementacion y no como correccion.
-=-
I mean that when you edit within the EditBox, even we press the insert key, no different behavior between um overwrite text already exists and the text insertion mode. So you can better understand Claudio and notice in this link (executable and source)
Carlos Britos wrote:The overwrite mode is not working.
I think this never worked in the EditBox HMG. Just back to expose what Carlos was referring. It would be important as a new implementation and not as correction of it.
Re: EditBox control: increase capacity
Posted: Thu Jul 11, 2013 3:34 pm
by srvet_claudio
Pablo César wrote:I think this never worked in the EditBox HMG. Just back to expose what Carlos was referring. It would be important as a new implementation and not as correction of it.
Ok now I understand, the problem is that EditBox control does not support these functions, you must be implemented to "lung".
Re: EditBox control: increase capacity
Posted: Thu Jul 11, 2013 8:01 pm
by Carlos Britos
srvet_claudio wrote:
Best Regards,
Claudio
Hi Claudio
This code works ok, thanks Maestro.
Re: EditBox control: increase capacity
Posted: Thu Jul 11, 2013 10:08 pm
by Carlos Britos
srvet_claudio wrote:Pablo César wrote:I think this never worked in the EditBox HMG. Just back to expose what Carlos was referring. It would be important as a new implementation and not as correction of it.
Ok now I understand, the problem is that EditBox control does not support these functions, you must be implemented to "lung".
Hi
Can anyone test this code?
Code: Select all
/*
* HMG - Harbour Win32 GUI library Demo
*
* Copyright 2010 Roberto Lopez <mail.box.hmg@gmail.com>
* https://www.hmgforum.com//
*/
#include "hmg.ch"
Function Main
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 640 HEIGHT 480 ;
TITLE 'HMG Demo' ;
ICON 'DEMO.ICO' ;
MAIN
@ 30,10 EDITBOX Edit_1 ;
WIDTH 410 ;
HEIGHT 140 ;
VALUE 'EditBox!!'
SendMessage (GetControlHandle("Edit_1","Form_1"), 197, 0, 0 )
DEFINE BUTTON D
ROW 250
COL 290
WIDTH 130
CAPTION '_GetCaretPos'
ACTION msginfo( hb_NtoS( _GetCaretPos( "Edit_1", "Form_1" ) ) )
END BUTTON
END WINDOW
Form_1.Center()
Form_1.Activate()
Return Nil
*-----------------------------------------------------------------------------*
Function _GetCaretPos ( ControlName , FormName )
*-----------------------------------------------------------------------------*
Local i, nStart, nEnd
i := GetControlIndex ( ControlName, FormName )
If i == 0
Return 0
EndIf
HMG_SendMessage ( _HMG_SYSDATA [3] [i] , 176, @nStart, @nEnd )
Return nEnd
#pragma BEGINDUMP
#include <windows.h>
#include "hbapi.h"
HB_FUNC (HMG_SENDMESSAGE)
{ HWND hWnd = (HWND) hb_parnl(1);
UINT nMsg = (UINT) hb_parnl(2);
LONG wParam = (LONG) hb_parnl(3);
LONG lParam = (LONG) hb_parnl(4);
LONG lResult;
lResult = (LONG) SendMessage (hWnd, nMsg, (WPARAM) &wParam, (LPARAM) &lParam);
hb_retnl ((LONG) lResult);
if (HB_ISBYREF(3))
hb_stornl ((LONG) wParam, 3);
if (HB_ISBYREF(4))
hb_stornl ((LONG) lParam, 4);
}
#include "SET_COMPILE_HMG_UNICODE.ch"
#include "HMG_UNICODE.h"
#define _WIN32_IE 0x0500
#define HB_OS_WIN_32_USED
#include <shlobj.h>
#include <windows.h>
#include <commctrl.h>
#include "hbapi.h"
#include "hbvm.h"
#include "hbstack.h"
#include "hbapiitm.h"
#include "winreg.h"
#include "tchar.h"
LRESULT APIENTRY SubClassFunc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
static WNDPROC lpfnOldWndProc;
HB_FUNC( INITEDITBOX )
{
HWND hwnd;
HWND hbutton;
int Style ;
hwnd = (HWND) hb_parnl (1);
Style = ES_MULTILINE | ES_WANTRETURN | WS_CHILD ;
if ( hb_parl (10) )
{
Style = Style | ES_READONLY ;
}
if ( ! hb_parl (11) )
{
Style = Style | WS_VISIBLE ;
}
if ( ! hb_parl (12) )
{
Style = Style | WS_TABSTOP ;
}
if ( ! hb_parl (13) )
{
Style = Style | WS_VSCROLL ;
}
else
{
Style = Style | ES_AUTOVSCROLL ;
}
if ( ! hb_parl (14) )
{
Style = Style | WS_HSCROLL ;
}
hbutton = CreateWindowEx( WS_EX_CLIENTEDGE, _TEXT("EDIT"), _TEXT(""),
Style ,
hb_parni(3), hb_parni(4) , hb_parni(5), hb_parni(6) ,
hwnd,(HMENU)hb_parni(2) , GetModuleHandle(NULL) , NULL ) ;
SendMessage ( hbutton , (UINT)EM_LIMITTEXT ,(WPARAM) hb_parni(9) , (LPARAM) 0 ) ;
lpfnOldWndProc = (WNDPROC) SetWindowLong( (HWND) hbutton, GWL_WNDPROC, (LONG) SubClassFunc);
hb_retnl ( (LONG) hbutton );
}
LRESULT APIENTRY SubClassFunc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg )
{
case WM_CHAR: //
if ( ( ! GetKeyState( VK_INSERT ) == 0 ) && ( wParam != VK_RETURN ) && ( wParam != VK_BACK ) )
SendMessage( hWnd, WM_KEYDOWN, VK_DELETE, 0 ) ;
break;
return CallWindowProc( lpfnOldWndProc, hWnd, 0, 0, 0 ) ;
}
return CallWindowProc( lpfnOldWndProc, hWnd, msg, wParam, lParam ) ;
}
#pragma ENDDUMP