Set Date and Time to Operacional System

HMG Samples and Enhancements

Moderator: Rathinagiri

User avatar
esgici
Posts: 4515
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 389 times
Been thanked: 111 times
Contact:

Re: Set Date and Time to Operacional System

Post by esgici » Mon Jan 16, 2012 9:31 pm

Thanks a lot Pablo

Saludos

--

Esgici
Viva INTERNATIONAL HMG :D

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Tue Jan 17, 2012 5:47 pm

I am looking a example of GETTEXTSIZE which I believe is already in Harbour. This function is used to get len of string in pixels. These are C function for it, but it´s with stil some errors:

Code: Select all

#pragma BEGINDUMP

#include <hbapi.h>
#include <hbapiitm.h>
#include <windows.h>


HB_FUNC( GETTEXTEXTENTPOINT32 ) //hdc,cText
{
	HDC hdc = (HDC) hb_parnl(1);
	char * pstr = hb_parcx(2);
	SIZE sz ;
	if ( GetTextExtentPoint32( hdc, pstr, strlen(pstr), &sz ) )
	{
		PHB_ITEM * aSize ;
		hb_arrayNew(&aSize,2);
		hb_itemPutNI( hb_arrayGetItemPtr( &aSize, 1 ), sz.cx );
		hb_itemPutNI( hb_arrayGetItemPtr( &aSize, 2 ), sz.cy );
		hb_itemReturnForward( &aSize );
		hb_arrayRelease( &aSize );
	}
}


HB_FUNC( GETTEXTSIZE )
{
	char * pstr = hb_parc(2);
	SIZE sz;
	PHB_ITEM aMetr = _itemArrayNew( 2 );
	PHB_ITEM temp;

	GetTextExtentPoint32( (HDC) HB_PARHANDLE(1), pstr, strlen( pstr ), 
	&sz );

	temp = hb_itemPutNL( NULL, sz.cx );
	hb_itemArrayPut( aMetr, 1, temp );
	hb_itemRelease( temp );

	temp = hb_itemPutNL( NULL, sz.cy );
	hb_itemArrayPut( aMetr, 2, temp );
	hb_itemRelease( temp );

	hb_itemReturn( aMetr );
	hb_itemRelease( aMetr );
}

#pragma ENDDUMP
Errors at compiling is:
undefined reference to `_itemArrayNew'
.hbmk/win/mingw/main.o:main.c:(.text+0x34): undefined reference to `HB_PARHANDLE'
.hbmk/win/mingw/main.o:main.c:(.text+0x1db): undefined reference to `hb_arrayRelease'
I will appreciate your help if somebody already made it works.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
Rathinagiri
Posts: 5263
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 169 times
Been thanked: 172 times
Contact:

Post by Rathinagiri » Tue Jan 17, 2012 6:05 pm

Hi,

Can you please tell me the exact location of these c source code?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Wed Jan 18, 2012 1:28 am

Hi Rathinagiri, thank you for your interest. I give my way, but it is not a canonic solution.

Look what I done:

Code: Select all

Static Function WidthString(cString)
Local i, nTam := 0.0

For i=1 to Len(cString)
   cChar := Sub str(cString,i,1)
   Do Case
      Case cChar $ "ifjl,t.;:"+Chr(126)+Chr(125)+Chr(91)+Chr(93)+"-+*()"+Chr(34)+"'!íIÍ\|/"
           nTam := nTam + 2.5
     Case cChar $ "qweryuopasdghkçzxcvbnmáéóúàâêôãõ<>_=?"
           nTam := nTam + 5.0
      Case cChar $ "#$%"+Chr(38)
           nTam := nTam + 6.0
      Case cChar $ "QERTYUOPASDFGHJKLÇZXCVBNMÁÉÓÚÀÂÊÔÃÕ"
           nTam := nTam + 8.0
      Case cChar $ "W"
           nTam := nTam + 10.0
      Case cChar $ Chr(64)
           nTam := nTam + 11.0
      Otherwise
           nTam := nTam + 9.0
   Endcase
Next
Return nTam
But This function was made based Arial font size 9.

The source of my searching is:
http://www.rhinocerus.net/forum/lang-xh ... int32.html
Also this function is in C:\MiniGUI\Harbour\lib\hbwin.lib, C:\hmg.3.0.40\HARBOUR\lib\win\mingw\libhbwin.a and C:\hmg.3.0.40\HARBOUR\CHANGELOG

And I attaching a new version: 3.1

Note: Server with difficulties to accept "sub str" (not separated, because server claims with error). So please note in the line cChar := Sub_str(cString,i,1), in the words sub and str it is sentences together not separated.
Last edited by Pablo César on Fri Jan 20, 2012 11:11 am, edited 1 time in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Fri Jan 20, 2012 10:42 am

Implementations that have been made in Version 3.2:
  1. By language files for easy definition in other languages
  2. StatusBar resizable, for lack of space in the window sometimes prevents the display completely. Then the user clicks on top and increases and decreases for view.
  3. Compatibility with previous versions of Windows to Windows XP (Win98)
  4. Trying to run a second time, the utility checks and resets the focus of the program was running. Not to use the SET WARNING OFF MULTIPLE
  5. A function that measures the string in pixels to use their best display in the StatusBar
  6. The ContextMenu is more beautiful because it uses features 3 styles
  7. Provide a screen "About Me" or "Leia-me" in Portuguese that shows the tools used for development on the version and author. This screen has timed out, ie, the window closes automatically after 20 seconds
  8. Was inserted WAlert function () which replaces MsgYesNo () because the buttons are not in the selected language. I think this is a bug of this tool not only as the great majority, since it should not take the OS.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Fri Jan 20, 2012 11:18 am

Implementations have been made in version 3.3:
  1. Font of the StatusBar was changed to Courier New, because it is a monospace one and easy for lengh measurement (in testing).
  2. Implemented _CenterWindow function () and also used C_Center () instead of Form.Center [/ b] or Center window [/ b]
  3. Was implemented MyALERT function () replacing WAlert (), adding a RichEditBox to display better (with vertical scroll bars when necessary) messages. Was made available three colors and an option to screen position by row, in order to show in better way a complete screen.
  4. Were inserted more functions such as text alignment like as justified() to fix texts centered and justified in MyALERT()


See screenshots from MyAlert():
Image
Image
Image
Last edited by Pablo César on Fri Jan 20, 2012 6:51 pm, edited 1 time in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
esgici
Posts: 4515
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 389 times
Been thanked: 111 times
Contact:

Post by esgici » Fri Jan 20, 2012 12:15 pm

Hola Pablo
Pablo César wrote:Implementations have been made in version 3.3:
Thanks a lot :)

Saludos

--

Esgici
Viva INTERNATIONAL HMG :D

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Fri Jan 20, 2012 6:51 pm

In version 3.4 has been done:

Windows 7 and I believe also in Vista and later, for security reasons does not allows to change the date and time if UAC (User Account Control) is enabled. Then I remembered my Win_util available also here and added an option to call the operating system clock. Intercepted the message "A required privilege is not held by the client." and calls the Windows clock in the case. Also fix a bug on the mouse click on Internet Explorer window to capture the screen of the page and get the official date and time.
Last edited by Pablo César on Sat Jan 21, 2012 4:41 am, edited 1 time in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Sat Jan 21, 2012 4:41 am

In version 3.5 the following bugs were fixed:
  1. Function are accepting even date/time are inconsistent.
  2. Error handling of output in file for network stations.
  3. Check the version of IExplorer, since the routine is only valid with version 6.00 or later.
  4. Added the path where the application is located, specially when Windows is startuping and also for images files and mem file which is recording last setup. It was then used GetStartUpFolder().
  5. It was replaced Justify function by CharSpread() and CharRepl() functions, which are very much simple and efficient.
  6. There are new items added in languages files.
Last edited by Pablo César on Tue Jan 24, 2012 3:57 pm, edited 1 time in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Tue Jan 24, 2012 3:57 pm

In version 3.6 was implemented to enable a Hyperlink to read a file .Doc that as according was it been selected language will be in Portuguese or in English. It is an instruction for the application to run as administrator and be able to change date/time by the properties of the executable in Windows 7.

Image

Note: Was corrected a bug when Windows was not ISVISTAORLATER. Please download RAR file again.
Attachments
DataHora.rar
Version 3.6
(1.02 MiB) Downloaded 472 times
Last edited by Pablo César on Tue Jan 24, 2012 10:15 pm, edited 3 times in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

Post Reply