Code: Select all
/*
* HMG - Harbour Win32 GUI library Demo
*
* Copyright 2010 Roberto Lopez <mail.box.hmg@gmail.com>
* http://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