topic stringlengths 1 63 | text stringlengths 1 577k ⌀ |
|---|---|
clausole When...Hide a size of Dialog - strange - RESOLVED | Silvio, please ADD:
[code=fw:1h5afpyn]<div class="fw" id="{CB}" style="font-family: monospace;"><br /> <!-- Windows <span style="color: #000000;">10</span> --><br /> <supportedOS <span style="color: #0000ff;">Id</span>=<span style="color: #ff0000;">"{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"</span>/><br /> </div>[/code:1h5afpyn]
look this:
[url:1h5afpyn]https://github.com/eladkarako/manifest/tree/master/example_manifests[/url:1h5afpyn]
WOW!!
Regards, saludos. |
clausole When...Hide a size of Dialog - strange - RESOLVED | Dear Silvio,
[url:mciz12iy]https://learn.microsoft.com/en-us/answers/questions/490947/windows-11-os-id.html[/url:mciz12iy]
Regards, saludos. |
clausole When...Hide a size of Dialog - strange - RESOLVED | [b:8fhxm6q1]FOUND THE PROBLEM [/b:8fhxm6q1]
DEFINE DIALOG oDlg ;
SIZE nWidth, nHeight PIXEL ;
TITLE cTitle ;
COLOR CLR_BLACK,CLR_WHITE
instead of
DEFINE DIALOG oDlg ;
SIZE nWidth, nHeight PIXEL ;
TITLE cTitle ;
COLOR CLR_BLACK,CLR_WHITE [b:8fhxm6q1]TRANSPARENT[/b:8fhxm6q1]
it seems [b:8fhxm6q1]TRANSPARENT [/b:8fhxm6q1] give problem
the resource I used that of Fwh folder ( my realease December 2021 to March 2022)
[img:8fhxm6q1]https://i.postimg.cc/2596NL70/yes.gif[/img:8fhxm6q1]
I put [b:8fhxm6q1]TRANSPARENT[/b:8fhxm6q1] [b:8fhxm6q1]ONLY [/b:8fhxm6q1] on SAY CONTROLS and run ok
[img:8fhxm6q1]https://i.postimg.cc/0ydc8Djd/yes.gif[/img:8fhxm6q1] |
clausole When...Hide a size of Dialog - strange - RESOLVED | Now run ok
[img:18gt9hz5]https://i.postimg.cc/x1VkLGbw/NOW-RUN.png[/img:18gt9hz5] |
clausole When...Hide a size of Dialog - strange - RESOLVED | Dear Silvio, Congratulations. Even so, please test with this MANIFEST model using COLORS in the controls, please.
Estimado Silvio, Felicitaciones. Aun así, prueba con este modelo MANIFEST usando COLORES en los controles, por favor.
WINDOWS10.MANIFEST
[code=fw:1425r2sq]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><?xml version=<span style="color: #ff0000;">"1.0"</span> encoding=<span style="color: #ff0000;">"UTF-8"</span> standalone=<span style="color: #ff0000;">"yes"</span>?> <br /><assembly xmlns=<span style="color: #ff0000;">"urn:schemas-microsoft-com:asm.v1"</span> manifestVersion=<span style="color: #ff0000;">"1.0"</span>> <br /> <dependency optional=<span style="color: #ff0000;">"yes"</span>> <br /> <dependentAssembly> <br /> <assemblyIdentity <span style="color: #0000ff;">name</span>=<span style="color: #ff0000;">"Microsoft.Windows.Common-Controls"</span> <br /> version=<span style="color: #ff0000;">"6.0.0.0"</span> publicKeyToken=<span style="color: #ff0000;">"6595b64144ccf1df"</span> <br /> type=<span style="color: #ff0000;">"win32"</span> processorArchitecture=<span style="color: #ff0000;">"*"</span> language=<span style="color: #ff0000;">"*"</span> /> <br /> </dependentAssembly> <br /> </dependency> <br /> <application xmlns=<span style="color: #ff0000;">"urn:schemas-microsoft-com:asm.v3"</span>> <br /> <windowsSettings> <dpiAware xmlns=<span style="color: #ff0000;">"http://schemas.microsoft.com/SMI/2005/WindowsSettings"</span>>true/PM</dpiAware> </windowsSettings> <br /> <windowsSettings> <dpiAwareness xmlns=<span style="color: #ff0000;">"http://schemas.microsoft.com/SMI/2016/WindowsSettings"</span>>PerMonitorV2,PerMonitor</dpiAwareness> </windowsSettings> <br /> <windowsSettings> <longPathAware xmlns=<span style="color: #ff0000;">"http://schemas.microsoft.com/SMI/2016/WindowsSettings"</span>>true</longPathAware> </windowsSettings> <br /> <windowsSettings> <heapType xmlns=<span style="color: #ff0000;">"http://schemas.microsoft.com/SMI/2020/WindowsSettings"</span>>SegmentHeap</heapType> </windowsSettings> <br /> </application> <br /> <trustInfo xmlns=<span style="color: #ff0000;">"urn:schemas-microsoft-com:asm.v3"</span>> <br /> <security> <br /> <requestedPrivileges> <br /> <requestedExecutionLevel level=<span style="color: #ff0000;">"asInvoker"</span> uiAccess=<span style="color: #ff0000;">"false"</span> /> <br /> </requestedPrivileges> <br /> </security> <br /> </trustInfo> <br /> <compatibility xmlns=<span style="color: #ff0000;">"urn:schemas-microsoft-com:compatibility.v1"</span>> <br /> <application> <br /> <supportedOS <span style="color: #0000ff;">Id</span>=<span style="color: #ff0000;">"{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"</span> /> <br /> <supportedOS <span style="color: #0000ff;">Id</span>=<span style="color: #ff0000;">"{1f676c76-80e1-4239-95bb-83d0f6d0da78}"</span> /> <br /> <supportedOS <span style="color: #0000ff;">Id</span>=<span style="color: #ff0000;">"{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"</span> /> <br /> <supportedOS <span style="color: #0000ff;">Id</span>=<span style="color: #ff0000;">"{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"</span> /> <br /> <supportedOS <span style="color: #0000ff;">Id</span>=<span style="color: #ff0000;">"{e2011457-1546-43c5-a5fe-008deee3d3f0}"</span> /> <br /> </application> <br /> </compatibility> <br /></assembly><br /> </div>[/code:1425r2sq]
Gracias, thanks.
Regards, saludos. |
clausole When...Hide a size of Dialog - strange - RESOLVED | Dear Silvio, complete download using WINDOWS10.MANIFEST. Test please.
Estimado Silvio, descarga completa usando WINDOWS10.MANIFEST. prueba por favor.
Link:
[url:15vnxsbv]https://mega.nz/file/cMkFwAQa#km42FPaVgu3ko93BuYTsdX9aJFtxkyWVGPmsQ4aSd38[/url:15vnxsbv]
Gracias, thanks.
Regards, saludos. |
clausula transparent urllink no funciona | Buenas tardes para todos
Como dice el encabezado parece que la clausula TRANSPARENT del control urlink no funciona correctamente, lo tengo definido en un dialogo el cual tiene un brush, pero se ve blanco.
[img:2wbk1omz]https://www.hymplus.com/forofw/URLINK.png[/img:2wbk1omz]
[code=fw:2wbk1omz]<div class="fw" id="{CB}" style="font-family: monospace;"><br /> <span style="color: #0000ff;">REDEFINE</span> URLLINK <span style="color: #0000ff;">ID</span> <span style="color: #000000;">104</span> URL <span style="color: #ff0000;">"https://hymplus.com/"</span> <span style="color: #0000ff;">OF</span> oDlg TOOLTIP <span style="color: #ff0000;">"Visita nuestro sitio web "</span> ;<br /> TRANSPARENT CLRINIT CLR_BLUE CLROVER CLR_MAGENTA <br /> </div>[/code:2wbk1omz] |
clausula transparent urllink no funciona | Leandro, desde la versión FWH17.01 que no funciona. Puede usar BRUSH. Mas no TRANSPARENT en el DIALOG. Saludos. |
clear IMAGE | Hello,
I want to set a button (ID 102) to clear the Image:
[code=fw:18lgnizq]<div class="fw" id="{CB}" style="font-family: monospace;"> <span style="color: #0000ff;">REDEFINE</span> <span style="color: #0000ff;">IMAGE</span> oBmpFoto1 <span style="color: #0000ff;">ID</span> <span style="color: #000000;">103</span> <span style="color: #0000ff;">OF</span> oFld:<span style="color: #000000;">aDialogs</span><span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span> <span style="color: #0000ff;">UPDATE</span> ;<br /> FILENAME oData:<span style="color: #000000;">FOTO</span> ;<br /> <span style="color: #0000ff;">ON</span> <span style="color: #0000ff;">CLICK</span> <span style="color: #000000;">(</span> oData:<span style="color: #000000;">FOTO</span> := _CargaFoto <span style="color: #000000;">(</span>oBmpFoto1, oDlg<span style="color: #000000;">)</span> <span style="color: #000000;">)</span> <span style="color: #0000ff;">ADJUST</span> <br /><br /> <span style="color: #0000ff;">REDEFINE</span> <span style="color: #0000ff;">BUTTON</span> <span style="color: #0000ff;">ID</span> <span style="color: #000000;">101</span> <span style="color: #0000ff;">OF</span> oFld:<span style="color: #000000;">aDialogs</span><span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span> ;<br /> <span style="color: #0000ff;">ACTION</span> <span style="color: #000000;">(</span> oData:<span style="color: #000000;">FOTO</span> := _CargaFoto <span style="color: #000000;">(</span>oBmpFoto1, oDlg<span style="color: #000000;">)</span> <span style="color: #000000;">)</span> <br /><br /> <span style="color: #0000ff;">REDEFINE</span> <span style="color: #0000ff;">BUTTON</span> <span style="color: #0000ff;">ID</span> <span style="color: #000000;">102</span> <span style="color: #0000ff;">OF</span> oFld:<span style="color: #000000;">aDialogs</span><span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span> ;<br /> <span style="color: #0000ff;">ACTION</span> <span style="color: #000000;">(</span> oData:<span style="color: #000000;">FOTO</span> := <span style="color: #ff0000;">""</span>, alert<span style="color: #000000;">(</span>odata:<span style="color: #000000;">foto</span><span style="color: #000000;">)</span>, oBmpFoto1:<span style="color: #0000ff;">Refresh</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span>, oFld:<span style="color: #0000ff;">Update</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span>, oFld:<span style="color: #0000ff;">Refresh</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span>, oDlg:<span style="color: #0000ff;">Refresh</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span> <span style="color: #000000;">)</span><br /> </div>[/code:18lgnizq]
But despite I set oData:Foto to "" and I call refresh and update, the previous picture is still there, I need to remove it.
Maybe I miss something or it is a bug.
Thank you. |
clear IMAGE | I had the same problem in my imaging product. I got around it by creating a blank image "blank,jpg" and using it when there is no image wanted. |
clear IMAGE | Lucas
Here is a snipit of code I use for Images with some help and advice from our good friend Uwe.
Have a look at how the image is defined with oImage and bPainted then deleted with the function DelImage()
Rick Lipkin
[code=fw:xscojx5j]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><span style="color: #B900B9;">// images</span><br /><br /><span style="color: #0000ff;">REDEFINE</span> <span style="color: #0000ff;">IMAGE</span> oImage <span style="color: #0000ff;">ID</span> <span style="color: #000000;">701</span> FILENAME <span style="color: #00C800;">NIL</span> <span style="color: #0000ff;">of</span> oUsers ;<br /> <span style="color: #0000ff;">PIXEL</span> <span style="color: #0000ff;">ADJUST</span> BORDER<br /><br /> oImage:<span style="color: #000000;">bPainted</span> := <span style="color: #000000;">{</span> |hDC| DRAW_IMG<span style="color: #000000;">(</span> oImage, hDC, cImage, cPicFileName <span style="color: #000000;">)</span> <span style="color: #000000;">}</span><br /><br /><span style="color: #0000ff;">REDEFINE</span> <span style="color: #0000ff;">GET</span> oGET <span style="color: #0000ff;">var</span> cImage <span style="color: #0000ff;">ID</span> <span style="color: #000000;">706</span> <span style="color: #0000ff;">of</span> oUsers <span style="color: #0000ff;">PICTURE</span> <span style="color: #ff0000;">"@!"</span> READONLY <span style="color: #B900B9;">// displays the filename only</span><br /><br /><span style="color: #0000ff;">REDEFINE</span> <span style="color: #0000ff;">BTNBMP</span> oButt4 <span style="color: #0000ff;">ID</span> <span style="color: #000000;">702</span> <span style="color: #0000ff;">of</span> oUsers ;<br /> <span style="color: #0000ff;">RESOURCE</span> <span style="color: #ff0000;">"ADD16"</span>,<span style="color: #ff0000;">"DADD16"</span>,<span style="color: #ff0000;">"DADD16"</span> ;<br /> <span style="color: #0000ff;">PROMPT</span> <span style="color: #ff0000;">"Import "</span> <span style="color: #0000ff;">LEFT</span> <span style="color: #000000;">2007</span>;<br /> <span style="color: #0000ff;">ACTION</span> <span style="color: #000000;">(</span> GetImage<span style="color: #000000;">(</span> @oImage,oRsPet,oUsers,@cImage,oGet,@cPicFileName <span style="color: #000000;">)</span>,;<br /> _ChkButtons<span style="color: #000000;">(</span> cMode,oRsPet,oButt4,oButt5,oButt6,oButt7<span style="color: #000000;">)</span><span style="color: #000000;">)</span><br /><br /><span style="color: #0000ff;">REDEFINE</span> <span style="color: #0000ff;">BTNBMP</span> oButt5 <span style="color: #0000ff;">ID</span> <span style="color: #000000;">703</span> <span style="color: #0000ff;">of</span> oUsers ;<br /> <span style="color: #0000ff;">RESOURCE</span> <span style="color: #ff0000;">"EDIT16"</span>,<span style="color: #ff0000;">"DEDIT16"</span>,<span style="color: #ff0000;">"DEDIT16"</span> ;<br /> <span style="color: #0000ff;">PROMPT</span> <span style="color: #ff0000;">"Export "</span> <span style="color: #0000ff;">LEFT</span> <span style="color: #000000;">2007</span>;<br /> <span style="color: #0000ff;">ACTION</span> <span style="color: #000000;">(</span> ExportImage<span style="color: #000000;">(</span> oRsPet,<span style="color: #000000;">0</span> <span style="color: #000000;">)</span> <span style="color: #000000;">)</span><br /><br /><span style="color: #0000ff;">REDEFINE</span> <span style="color: #0000ff;">BTNBMP</span> oButt6 <span style="color: #0000ff;">ID</span> <span style="color: #000000;">704</span> <span style="color: #0000ff;">of</span> oUsers ;<br /> <span style="color: #0000ff;">RESOURCE</span> <span style="color: #ff0000;">"DELETE16"</span>,<span style="color: #ff0000;">"DDELETE16"</span>, <span style="color: #ff0000;">"DDELETE16"</span> ;<br /> <span style="color: #0000ff;">PROMPT</span> <span style="color: #ff0000;">"Delete "</span> <span style="color: #0000ff;">LEFT</span> <span style="color: #000000;">2007</span>;<br /> <span style="color: #0000ff;">ACTION</span> <span style="color: #000000;">(</span> DelImage<span style="color: #000000;">(</span>@oImage,oRsPet,oUsers,oGet,@cImage,@cPicFileName <span style="color: #000000;">)</span>,;<br /> _ChkButtons<span style="color: #000000;">(</span> cMode,oRsPet,oButt4,oButt5,oButt6,oButt7<span style="color: #000000;">)</span><span style="color: #000000;">)</span><br /><br /><span style="color: #0000ff;">REDEFINE</span> <span style="color: #0000ff;">BTNBMP</span> oButt7 <span style="color: #0000ff;">ID</span> <span style="color: #000000;">705</span> <span style="color: #0000ff;">of</span> oUsers ;<br /> <span style="color: #0000ff;">RESOURCE</span> <span style="color: #ff0000;">"VIEW16"</span>,<span style="color: #ff0000;">"DVIEW16"</span>,<span style="color: #ff0000;">"DVIEW16"</span> ;<br /> <span style="color: #0000ff;">PROMPT</span> <span style="color: #ff0000;">"Print "</span> <span style="color: #0000ff;">LEFT</span> <span style="color: #000000;">2007</span>;<br /> <span style="color: #0000ff;">ACTION</span> <span style="color: #000000;">(</span> PrintImage<span style="color: #000000;">(</span> oRsPet,<span style="color: #000000;">0</span> <span style="color: #000000;">)</span> <span style="color: #000000;">)</span><br /><br /><span style="color: #B900B9;">// end images</span><br /><br /><span style="color: #B900B9;">//------------- Image-Brush from Uwe ----------</span><br /><span style="color: #00C800;">Static</span> FUNC Draw_Img<span style="color: #000000;">(</span> oImage, hDC, cImage, cPicFileName <span style="color: #000000;">)</span><br /><br /><span style="color: #00C800;">LOCAL</span> oBrush,cDefa<br /><span style="color: #00C800;">LOCAL</span> aRect := GETCLIENTRECT<span style="color: #000000;">(</span> oImage:<span style="color: #000000;">hWnd</span> <span style="color: #000000;">)</span><br /><br />cDefa := set<span style="color: #000000;">(</span><span style="color: #000000;">7</span><span style="color: #000000;">)</span><br /><br /><span style="color: #00C800;">If</span> cPicFileName = <span style="color: #ff0000;">" "</span> <span style="color: #B900B9;">// ad mode because blank .. cImage passed as is</span><br /><span style="color: #00C800;">Else</span><br /> cImage := cDefa+<span style="color: #ff0000;">"<span style="color: #000000;">\P</span>ictures<span style="color: #000000;">\"</span>+alltrim( cImage )<br />Endif<br /><br />// added for on paint<br />SysReFresh()<br /><br />IF FILE( cImage )<br /> DEFINE IMAGE oBrush FILENAME cImage<br /> PalBmpDraw( hDC, 0, 0, oBrush:hBitmap, , aRect[4], aRect[3] )<br /> oBrush:End()<br />ENDIF<br /><br />RETURN( NIL )<br /><br />//----------------------------------------------------------------------------//<br />Static Func DelImage( oImage,oRsPet,oDlg,oGet,cImage,cPicFileName )<br /><br />LOCAL Saying,cFILE,cDefa<br /><br />cDefa := set(7)<br />cFile := oRsPet:Fields("</span>PicFileName<span style="color: #ff0000;">"):Value<br /><br />If cFile = "</span> <span style="color: #ff0000;">" .or. empty( cFile )<br /> Saying := "</span>Sorry .. there is no <span style="color: #0000ff;">Image</span> <span style="color: #0000ff;">to</span> Delete<span style="color: #ff0000;">"<br /> MsgInfo( Saying )<br /> Return(.f.)<br />Endif<br /><br />Saying := "</span>Are you SURE you want <span style="color: #0000ff;">to</span> Delete this <span style="color: #0000ff;">Image</span> ?<span style="color: #ff0000;">"+chr(10)<br />Saying += cFile<br /><br />If MsgNoYes( Saying )<br /><br /> Ferase(cDefa+"</span>\Pictures\<span style="color: #ff0000;">"+alltrim(cFile))<br /> cImage := "</span> <span style="color: #ff0000;">"<br /> oGet:Refresh()<br /> oImage:Refresh()<br /> oDlg:ReFresh()<br /> SysReFresh()<br /><br /> cPicFileName := space(50)<br /> oRsPet:Fields("</span>PicFileName<span style="color: #ff0000;">"):Value := cPicFileName<br /> oRsPet:Update()<br /><br /> SysReFresh()<br /><br />Endif<br /><br />Return(nil)<br /></span></div>[/code:xscojx5j] |
clear IMAGE | Mr Lucas
Let me try to make it simple for you.
#1. If you want to change the image with a new image file :
ACTION ( oData:foto := <newfilename>, oImage:LoadBmp( oData:foto ) )
#2. If you want to clear image
ACTION ( oData:foto := "", ClearImage( oImage ) )
I shall give you a function to ClearImage
[code=fw:2bdiwwdo]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #00C800;">function</span> ClearImage<span style="color: #000000;">(</span> oBmp <span style="color: #000000;">)</span><br /><br /> WITH OBJECT oBmp<br /> PalBmpFree<span style="color: #000000;">(</span> :<span style="color: #000000;">hBitmap</span>, :<span style="color: #000000;">hPalette</span> <span style="color: #000000;">)</span><br /> :<span style="color: #000000;">hBitmap</span> := :<span style="color: #000000;">hPalette</span> := <span style="color: #000000;">0</span><br /> :<span style="color: #000000;">cBmpFile</span> := :<span style="color: #000000;">cResName</span> := <span style="color: #00C800;">nil</span><br /> :<span style="color: #0000ff;">Refresh</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /> END<br /><br /><span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span><br /> </div>[/code:2bdiwwdo]
We try to provide an appropriate method in the class in the next version. |
clear IMAGE | Lucas;
Try this oBmpFoto1:LoadImage("nada") |
clear IMAGE | [quote="elvira":1cy2g8c2]Lucas;
Try this oBmpFoto1:LoadImage("nada")[/quote:1cy2g8c2]
This also works. Giving a non-empty name, which is not an existing image file also works. This is a work around. |
clear IMAGE | From FWH 13.07, we can use
oImg:Clear() |
clear SAY? how? | Hello,
How I make to clean some SAYS in a DIALOG? I am making this:
@ 10,20 SAY OSAY VAR ' MY TEXT ' OF ODLG UPDATE
.
.
.
ODLG:UPDATE()
This command is cleaning the GETs but the SAYs is not cleaning.
Many thanks |
clear SAY? how? | [quote="syda":3g7p0eys]Hello,
How I make to clean some SAYS in a DIALOG? I am making this:
@ 10,20 SAY OSAY VAR ' MY TEXT ' OF ODLG UPDATE
.
.
.
ODLG:UPDATE()
This command is cleaning the GETs but the SAYs is not cleaning.
Many thanks[/quote:3g7p0eys]
Yo lo hago de l siguiente manera:
@ 10,20 oSay PROMPT "Mi texto" OF oDlg UPDATE
sin problemas. |
clear SAY? how? | @ 10,20 SAY oSay PROMPT "Mi texto" OF oDlg UPDATE
oSay:SetText( "" ) |
clear tImage | Hi all !I created image oIm:=tImage():New()oIm:LoadBmp(cFile) I want delete BMP from oIm. How do it ? |
clear tImage | Natter,if you want to change the image just load load a new oneoIM:SetBmp(cResName) or oIM:ReLoad( cResName, cBmpFile )if you want to delete the bmp you can destroy the object, just write oIM := nil or you try to load an unexisting image (not tested) |
clear tImage | ... delete the bmp you can destroy the object, just write oIM := nil or you try to load an unexisting image (not tested)"I do it. It's not work |
clear tImage | try this:oIm:hbitmap := 0oIm:Refresh()Ralph |
clear tImage | It's not work |
clear tImage | [quote="Natter":4786jswb]It's not work[/quote:4786jswb]May be:[code:4786jswb]PalBmpFree( oIm:hBitMap, oIm:hPalette )[/code:4786jswb]Regards.Manuel Mercado. |
clear tImage | This is a sample:[code:3elmakxn]#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL oDlg, oImg
DEFINE DIALOG oDlg;
SIZE 700, 500
@ 1, 1 IMAGE oImg;
FILE "SFONDO.JPG";
SIZE 200, 200;
ADJUST
@ 0, 1 BUTTON "Save";
ACTION MSGINFO( oImg:SaveImage( "SAVED.JPG", 2 ) )
@ 0, 7 BUTTON "Print";
ACTION PRINT( oImg )
@ 0, 13 BUTTON "Paste";
ACTION ( oImg:LoadFromClipboard(),;
oImg:Refresh() )
@ 0, 19 BUTTON "Load";
ACTION ( oImg:LoadImage( , "GRIGIO.JPG" ),;
oImg:Refresh() )
@ 0, 25 BUTTON "Clear";
ACTION ( PalBmpFree( oImg:hBitMap, oImg:hPalette ),;
oImg:hBitmap := 0,;
oImg:hPalette := 0,;
oImg:cResName := NIL,;
oImg:cBmpFile := NIL,;
oImg:Refresh() )
ACTIVATE DIALOG oDlg;
CENTER
RETURN NIL
STATIC FUNCTION PRINT( oImg )
LOCAL oPrn
PRINT oPrn PREVIEW MODAL
PAGE
oPrn:SayImage( 0, 0, oImg, oPrn:nHorzRes(), oPrn:nVertRes() )
ENDPAGE
ENDPRINT
RETURN NIL[/code:3elmakxn]EMG |
clear tImage | It looks like the TImage class needs an End() method.James |
clear tImage | [quote="James Bott":3a94xwjj]It looks like the TImage class needs an End() method.[/quote:3a94xwjj]Hi James:It has. TImage is a TBitmap subclass, then inherits Destroy Method.Best regards.Manuel Mercado |
clear tImage | Thank everybody !@ 0, 25 BUTTON "Clear"; ACTION oImg:hBitmap := 0, ; oImg:cBmpFile := NIL,; oImg:Refresh() ) It work right ! |
clear tImage | [quote:2ztgfdbs]It has. TImage is a TBitmap subclass, then inherits Destroy Method. [/quote:2ztgfdbs]It is not clear if we should call the Destroy() method or the End() method. I see that TBitmap inherits from TControl which inherits from TWindow, yet I do not see the Destroy() method being called by any of those classes' End() method.To be consistant with all the other classes, the End() method should be the one that ends the object.James |
clear tImage | Natter,Try calling oImg:End() or oImg:Destroy() to see if one of those also works.James |
clear tImage | 1) calling oImg:End() - this method deleted control2) calling oImg:Destroy() - this method not work right. |
clear tImage | [quote="Natter":1utfjt0o]Thank everybody !
@ 0, 25 BUTTON "Clear";
ACTION oImg:hBitmap := 0, ;
oImg:cBmpFile := NIL,;
oImg:Refresh() )
It work right ![/quote:1utfjt0o]It's not enough. Please use what I put in my sample if you don't want to have resource leak.EMG |
clear the Clipboard | How to clear the Clipboard ( "Clipboard") of winxp, I am using __KEYBOARD (CHR (300)), to copy the screen, but when the Clipboard has no more space, the __KEYBOARD (CHR (300)) to working. |
clear the Clipboard | Please review fwh\samples\TestClip.prg |
clear the Clipboard | Antonio, if I open the area of transfer after using oClp:Clear(), this clean, but after a while the app not save the screen, this message: [b:3arpaf7e]Shut one or more application to free up more memory and try again.[/b:3arpaf7e]But if you leave the app, and return back to work.[code:3arpaf7e]
DEFINE ICON oIcon FILE "IMG.ICO"
DEFINE WINDOW oApp ICON oIcon
DEFINE CLIPBOARD oClp OF oApp
DEFINE TIMER oTmrIdx INTERVAL 10000 ACTION ( waitIdx( oTmrIdx,oTray,oIcon,oClp) ) OF oApp
ACTIVATE TIMER oTmrIdx
ACTIVATE WINDOW oApp ;
ON INIT oTray := TTrayIcon():New(oApp,oIcon,"",{|nRow,nCol|MenuTray(nRow,nCol,oTray,oIcon)},{|nRow,nCol|MenuTray(nRow,nCol,oTray,oIcon)}) ;
VALID oTray:End() ;
ON RIGHT CLICK oTray:SetIcon( oIcon, "Another" )
RETURN NIL
FUNCTION WaitIdx( oTmrIdx,oTray,oIcon,oClp)
local lFileExists := .f., cDir := CurDrive()+":\"+GetCurDir()+'\'
LOCAL Dir, vArq, vNum, nBytes
oTmrIdx:Deactivate()
__KEYBOARD(CHR(300))
SalvaTela("Tela",oIcon)
syswait(1)
oClp:Clear()
Release All
RESALLFREE()
SYSREFRESH()
CLEAR MEMORY
oTmrIdx:Activate()
[/code:3arpaf7e][/b] |
clear the Clipboard | Whats the source code for SalvaTela() ? |
clear the Clipboard | [code:1kbx2yj2]static function SalvaTela(cFileName,oIcon)
****************************************
LOCAL oTClip, hBitmap, fBit, Result := .f.
LOCAL oBmpImage
Default cFileName := "Tela.JPG"
cFileName := AllTrim(cFileName)
if AT('.jpg',lower(cFilename)) == 0
cFileName += '.JPG'
end
if file("Tela.BMP")
FERASE("Tela.BMP")
end
oTClip := TClipBoard():New() //New(WndMain())
syswait(.1)
hBitmap := oTClip:GetBitMap()
syswait(.3)
oTClip:Close()
oTClip:End()
Result := (hBitmap != 0)
if Result
fBit:=dibfrombitmap(hBitmap)
SysWait(.1)
dibwrite("Tela.BMP",fBit)
FISaveImg( "Tela.BMP", "Tela.JPG", 2, 70 )
Ferase("Tela.BMP")
Result := File("Tela.JPG")
else
?"error: not save"
end
Return Result
[/code:1kbx2yj2] |
clear the Clipboard | You have to release the bitmap and the dib, thats why you are consuming your sistem memory![code:3t0qkyxw]
if Result
fBit:=dibfrombitmap(hBitmap)
DeleteObject( hBitmap )
SysWait(.1)
dibwrite("Tela.BMP",fBit)
GlobalFree( fBit )
FISaveImg( "Tela.BMP", "Tela.JPG", 2, 70 )
Ferase("Tela.BMP")
Result := File("Tela.JPG")
else
?"error: not save"
end
[/code:3t0qkyxw] |
clear the Clipboard | Olá Antonio,No exemplo abaixo quando clico em "Salvar" a função "FISaveImg" sempre me retorna falso e o arquivo "TELA.JPG" é gerado com tamanho 0, porque ?[code:26m99243]
#include "fivewin.ch"
*************
function Main
*************
local oDlg, oIco, cTest := "Hello world! ", oClp
DEFINE ICON oIco FILE "\fwh\icons\fivewin.ico"
DEFINE DIALOG oDlg TITLE "I am a DialogBox" COLOR "W+/B" ;
ICON oIco
@ 1, 3 GET cTest
@ 3, 5 BUTTON "&Salvar" SIZE 40, 12 ;
ACTION SALVA( oDlg, oClp ) DEFAULT
@ 3, 16 BUTTON "&Cancel" SIZE 40, 12 ACTION oDlg:End()
DEFINE CLIPBOARD oClp OF oDlg
ACTIVATE DIALOG oDlg CENTERED ;
VALID MsgYesNo( "Do you want to end ?" )
oCLp:end()
return NIL
**************
function SALVA( oDlg, oClp )
**************
__KEYBOARD(CHR(300))
SalvaTela( "Tela" )
syswait(1)
oClp:Clear()
* Release All
* RESALLFREE()
SYSREFRESH()
* CLEAR MEMORY
return NIL
*************************
static function SalvaTela( cFileName )
*************************
LOCAL oTClip, hBitmap, fBit, Result := .f.
LOCAL oBmpImage
Default cFileName := "Tela.JPG"
cFileName := AllTrim(cFileName)
if AT('.jpg',lower(cFilename)) == 0
cFileName += '.JPG'
end
if file("Tela.BMP")
FERASE("Tela.BMP")
end
oTClip := TClipBoard():New() //New(WndMain())
syswait(.1)
hBitmap := oTClip:GetBitMap()
syswait(.3)
oTClip:Close()
oTClip:End()
Result := (hBitmap != 0)
if Result
fBit := dibfrombitmap( hBitmap )
SysWait(.1)
dibwrite( "Tela.BMP", fBit )
GlobalFree( fBit )
DeleteObject( hBitmap )
msgstop( FISaveImg( "Tela.BMP", "Tela.JPG", 2, 70 ) )
Ferase("Tela.BMP")
Result := File("Tela.JPG")
else
?"error: not save"
end
Return Result
static function FISAVEIMG( cSrcFile, cDstFile, nDstFormat, nQuality )
local nSrcFormat, hDib, hDib2, lOk
DEFAULT nQuality := 0
hLib = LoadLibrary( "freeimage.dll" )
nSrcFormat = FIGETFILETYPE( cSrcFile, 0 )
hDib = FILOAD( nSrcFormat, cSrcFile, 0 )
hDib2 = FICNV24( hDib )
lOk = FISAVE( nDstFormat, hDib2, cDstFile, nQuality )
FIUNLOAD( hDib )
FIUNLOAD( hDib2 )
FreeLibrary( hLib )
return lOk
//----------------------------------------------------------------------------//
DLL32 FUNCTION FIGETFILETYPE( cFileName AS LPSTR, nSize AS LONG ) AS LONG ;
PASCAL FROM "_FreeImage_GetFileType@8" LIB hLib
DLL32 FUNCTION FILOAD( nFormat AS LONG, cFileName AS LPSTR, nFlags AS LONG ) AS LONG ;
PASCAL FROM "_FreeImage_Load@12" LIB hLib
DLL32 FUNCTION FISAVE( nFormat AS LONG, hDib AS LONG, cFileName AS LPSTR, nFlags AS LONG ) AS BOOL ;
PASCAL FROM "_FreeImage_Save@16" LIB hLib
DLL32 FUNCTION FIUNLOAD( hDib AS LONG ) AS VOID ;
PASCAL FROM "_FreeImage_Unload@4" LIB hLib
DLL32 FUNCTION FICNV24( hDib AS LONG ) AS LONG ;
PASCAL FROM "_FreeImage_ConvertTo24Bits@4" LIB hLib
//----------------------------------------------------------------------------//
[/code:26m99243] |
clear the Clipboard | Rossine,Has comprobado que Tela.bmp esté correcto ? |
clear the Clipboard | Antonio,É gerado o arquivo TELA.BMP no tamanho de 1.920.054, mas não consigo abrí-lo com o ms-paint (paint). O paint me retorna a seguinte mensagem:"O Paint não pode ler este arquivo. Este não é um arquivo de bitmap válido ou não há suporte para o formato atualmente."Saludos,Rossine. |
clear the Clipboard | Rossine,has comprobado que despues de hacer:__KEYBOARD(CHR(300))haya una copia correcta de la imagen en el clipboard ?Por lo que comentas parece que el bitmap esta corrupto... |
clear the Clipboard | Antonio,[quote:1e8ljld8]
has comprobado que despues de hacer:
__KEYBOARD(CHR(300))
haya una copia correcta de la imagen en el clipboard ?
[/quote:1e8ljld8]Sim, após: __KEYBOARD(CHR(300)) ... executei o "PAINT" e colei a imagem que estava no clipboard.Este exemplo roda bem aí com você ?Saludos, |
clear the Clipboard | [quote="Rossine":231vord4]Antonio,
[quote:231vord4]
has comprobado que despues de hacer:
__KEYBOARD(CHR(300))
haya una copia correcta de la imagen en el clipboard ?
[/quote:231vord4][/quote:231vord4]Sim, após: __KEYBOARD(CHR(300)) ... executei o "PAINT" e colei a imagem que estava no clipboard.Baixe o arquivo TELA.BMP aqui: [url:231vord4]http://geocities.yahoo.com.br/qiinformatica2000/TELA.ZIP[/url:231vord4]Este exemplo roda bem aí com você ?Saludos, |
clear the Clipboard | Antonio,[quote:e3npfpn8]
has comprobado que despues de hacer:
__KEYBOARD(CHR(300))
haya una copia correcta de la imagen en el clipboard ?
[/quote:e3npfpn8]Sim, após: __KEYBOARD(CHR(300)) ... executei o "PAINT" e colei a imagem que estava no clipboard normalmente.Baixe o arquivo TELA.BMP aqui: [url:e3npfpn8]http://geocities.yahoo.com.br/qiinformatica2000/TELA.ZIP[/url:e3npfpn8]Este exemplo roda bem aí com você ?Saludos, |
clear the Clipboard | Olá,É possível fazer isto funcionar ? <!-- s:( --><img src="{SMILIES_PATH}/icon_sad.gif" alt=":(" title="Sad" /><!-- s:( --> Gracias,Rossine. |
clearing of archives | In a conversion procedure I have to clear all the archives and then populate them during the conversion.
The archives were all opened with Tdatabase and therefore in share
Archives are indexed with the! Deleted () clause
I don't know how to do the zeroing of archives and the dbpack since it cannot be done in Tdatabase
I don't know if it is better to delete all the archives and create them again or there is another solution |
clearing of archives | Are the new archives also changed in structures ?
ntx to cdx ? or also the same ? |
clearing of archives | The application that I am putting in place serves to make the substitutions of teachers every morning, I am changing it because we have decided to transform it into a network with user management.
Initially to use the procedure it was necessary to insert the data in all the archives (teachers, classes, classrooms, lessons etc.), to avoid entering everything from scratch because it is unnerving, I created a conversion procedure from an Excel archive that is generally used in all schools that automatically and in a short time extracts the data and puts them in the archives.
Then I proceed to convert from Excel to an import.dbf (oImport) archive
Then from this oImport archive I have to populate a series of archives (classes, classrooms, teachers, timetables, lessons, subjects, groups) through a procedure created by me, but the archives must be empty., And then the indexes must be recreated.
Probably this operation must be done by only one and not the shares, so before loading the conversion procedure I have to check if the users have logged out of the system. and only then can I call up the procedure and open the archives exclusively.
how should i check if a user is inside the system?
I have to check the user archive and the TAbations archive to see if there is a user who has entered the system
If there is someone I send a message "You must exit the system" through a procedure of messages between users of the same program and then I have to proceed and then I can use the archives in exclusive mode and use pack and zap.
Are there any other solutions? |
clearing of archives | I would concider
Make a conversion folder (for putting temporary dbf)
from the program folder copy the needed dbf's with the copy structure command to conversion folder (dbf's will be empty but have all fields)
fill the dbf in the conversion folder and generate the index file's
see if you have all users logged out and copy the files back to program folder. This process will be quick
This process could also be done timed ex. at 04.00 am so there is no one on the system.
The same can also be done in the program directory but there you can use the ZAP command or function. |
clearing of archives | hi,
i do create DBF / Index if not exist ...
you can open a DBF EXCLUSIVE when NO User is Connect ... than you can Ferase() it
to find out "who" is Connect to DBF is another Question |
clearing of archives | [quote:cv61jrjz]I don't know how to do the zeroing of archives and the dbpack since it cannot be done in Tdatabase
[/quote:cv61jrjz]
if the table is open exclusively,
oDbf:Zap()
oDbf:Pack() |
click a area of Tpanel control ( Creating a Piano) | I'm trying to create a small piano and I have this ( made with Tpanel control )
[img:20zontc1]http://www.eoeo.it/wp-content/uploads/2014/12/key.jpg[/img:20zontc1]
the problem...
when I click the first tPanel white ( first white key) control it sound the note C
when I click the first tPanel black ( first black key) control it sound the same the note C because this black control is over the first tpanel white
the problem is when I click the first black key I click the white first key and not the black key ... I hope you understood
How I can reslve it ? |
click a area of Tpanel control ( Creating a Piano) | Silvio,
You could check when the mouse is over the black key and disable the white ones |
click a area of Tpanel control ( Creating a Piano) | where i can see a sample for make it ? |
click a area of Tpanel control ( Creating a Piano) | Silvio,
Try this:
oBlackPanel:bMMoved = { | nRow, nCol | oWhitePanel:Disable() }
If that works, next we will see how to enable an array of oWhitePanels again |
click a area of Tpanel control ( Creating a Piano) | no ..not work good...
this sample :
[code=fw:ajdgk2r0]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"fivewin.ch"</span><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"constant.ch"</span><br /><br />REQUEST HB_GT_GUI_DEFAULT<br /><br /><span style="color: #00C800;">function</span> Test<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><span style="color: #00C800;">Local</span> oDlgPiano<br /><span style="color: #00C800;">Local</span> nBottom := <span style="color: #000000;">20</span><br /><span style="color: #00C800;">Local</span> nRight := <span style="color: #000000;">55</span><br /><span style="color: #00C800;">Local</span> nWidth := <span style="color: #0000ff;">Max</span><span style="color: #000000;">(</span> nRight * DLG_CHARPIX_W, <span style="color: #000000;">180</span> <span style="color: #000000;">)</span><br /><span style="color: #00C800;">Local</span> nHeight := nBottom * DLG_CHARPIX_H<br /><span style="color: #00C800;">Local</span> oBianco,oNero<br /><span style="color: #00C800;">Local</span> oBtnBianco<span style="color: #000000;">[</span><span style="color: #000000;">7</span><span style="color: #000000;">]</span><br /><span style="color: #00C800;">Local</span> oBtnNero<span style="color: #000000;">[</span><span style="color: #000000;">5</span><span style="color: #000000;">]</span><br /><span style="color: #00C800;">Local</span> oCursorBtn :=TCursor<span style="color: #000000;">(</span><span style="color: #000000;">)</span>:<span style="color: #00C800;">New</span><span style="color: #000000;">(</span>,<span style="color: #ff0000;">'HAND'</span><span style="color: #000000;">)</span><br /><br /><span style="color: #00C800;">Local</span> mTime:= <span style="color: #000000;">23</span><br /><br /> <span style="color: #0000ff;">DEFINE</span> <span style="color: #0000ff;">BRUSH</span> oBianco <span style="color: #0000ff;">COLOR</span> CLR_WHITE<br /> <span style="color: #0000ff;">DEFINE</span> <span style="color: #0000ff;">BRUSH</span> oNero <span style="color: #0000ff;">COLOR</span> CLR_BLACK<br /><br /><br /><br /> <span style="color: #0000ff;">DEFINE</span> <span style="color: #0000ff;">DIALOG</span> oDlgPiano ;<br /> <span style="color: #0000ff;">TITLE</span> i18n<span style="color: #000000;">(</span><span style="color: #ff0000;">"Virtual Piano"</span><span style="color: #000000;">)</span> ;<br /> <span style="color: #0000ff;">SIZE</span> nWidth, nHeight <span style="color: #0000ff;">PIXEL</span><br /><br /><br /><br /><br /> <span style="color: #B900B9;">//tasti bianchi</span><br /><br /> nRowTastoBianco:=<span style="color: #000000;">10</span><br /> nHeightTastoBianco:=<span style="color: #000000;">100</span><br /> ncolTastoBianco:= <span style="color: #000000;">2</span><br /> nwidthTastoBianco:= <span style="color: #000000;">20</span><br /><br /> oBtnBianco<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span>:=Tpanel<span style="color: #000000;">(</span><span style="color: #000000;">)</span>:<span style="color: #00C800;">New</span><span style="color: #000000;">(</span>nRowTastoBianco,ncolTastoBianco,nHeightTastoBianco,nwidthTastoBianco,oDlgPiano<span style="color: #000000;">)</span><br /> oBtnBianco<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span>:<span style="color: #000000;">oBrush</span>:= oBianco<br /> oBtnBianco<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span>:<span style="color: #000000;">bLClicked</span> := <span style="color: #000000;">{</span> | x, y, z | Note<span style="color: #000000;">(</span><span style="color: #000000;">1</span><span style="color: #000000;">)</span> <span style="color: #000000;">}</span><br /> oBtnBianco<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span>:<span style="color: #000000;">oCursor</span>:=oCursorBtn<br /> oBtnBianco<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span>:<span style="color: #000000;">bMMoved</span> = <span style="color: #000000;">{</span> | nRow, nCol | oBtnNero<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span>:<span style="color: #000000;">Disable</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span> <span style="color: #000000;">}</span><br /><br /> ncolTastoBianco:=oBtnBianco<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span>:<span style="color: #000000;">nRight</span><span style="color: #000000;">+2</span><br /> nwidthTastoBianco+= <span style="color: #000000;">20</span><br /><br /> oBtnBianco<span style="color: #000000;">[</span><span style="color: #000000;">2</span><span style="color: #000000;">]</span>:=Tpanel<span style="color: #000000;">(</span><span style="color: #000000;">)</span>:<span style="color: #00C800;">New</span><span style="color: #000000;">(</span>nRowTastoBianco,ncolTastoBianco,nHeightTastoBianco,nwidthTastoBianco,oDlgPiano<span style="color: #000000;">)</span><br /> oBtnBianco<span style="color: #000000;">[</span><span style="color: #000000;">2</span><span style="color: #000000;">]</span>:<span style="color: #000000;">oBrush</span>:= oBianco<br /> oBtnBianco<span style="color: #000000;">[</span><span style="color: #000000;">2</span><span style="color: #000000;">]</span>:<span style="color: #000000;">bLClicked</span> := <span style="color: #000000;">{</span> | x, y, z | Note<span style="color: #000000;">(</span><span style="color: #000000;">3</span><span style="color: #000000;">)</span> <span style="color: #000000;">}</span><br /> oBtnBianco<span style="color: #000000;">[</span><span style="color: #000000;">2</span><span style="color: #000000;">]</span>:<span style="color: #000000;">oCursor</span>:=oCursorBtn<br /><br /> nRowTastoNero:=<span style="color: #000000;">10</span><br /> nHeightTastoNero:=<span style="color: #000000;">60</span><br /> ncolTastoNero:= <span style="color: #000000;">15</span><br /> nwidthTastoNero:= <span style="color: #000000;">25</span><br /><br /><br /> oBtnNero<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span>:=Tpanel<span style="color: #000000;">(</span><span style="color: #000000;">)</span>:<span style="color: #00C800;">New</span><span style="color: #000000;">(</span>nRowTastoNero,ncolTastoNero,nHeightTastoNero,nwidthTastoNero,oDlgPiano<span style="color: #000000;">)</span><br /> oBtnNero<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span>:<span style="color: #000000;">bLClicked</span> := <span style="color: #000000;">{</span> | x, y, z | Note<span style="color: #000000;">(</span><span style="color: #000000;">2</span><span style="color: #000000;">)</span> <span style="color: #000000;">}</span><br /> oBtnNero<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span>:<span style="color: #000000;">oCursor</span>:=oCursorBtn<br /> oBtnNero<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span>:<span style="color: #000000;">bMMoved</span> = <span style="color: #000000;">{</span> | nRow, nCol | oBtnBianco<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span>:<span style="color: #000000;">Disable</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span>,oBtnBianco<span style="color: #000000;">[</span><span style="color: #000000;">2</span><span style="color: #000000;">]</span>:<span style="color: #000000;">Disable</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span> <span style="color: #000000;">}</span><br /><br /> <span style="color: #00C800;">for</span> k= <span style="color: #000000;">1</span> <span style="color: #0000ff;">to</span> <span style="color: #000000;">1</span><br /> oBtnNero<span style="color: #000000;">[</span>k<span style="color: #000000;">]</span>:<span style="color: #000000;">oBrush</span>:= oNero<br /> <span style="color: #00C800;">next</span><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> <span style="color: #0000ff;">ACTIVATE</span> <span style="color: #0000ff;">DIALOG</span> oDlgPiano<br /> RETUR <span style="color: #00C800;">NIL</span><br /><br /><br /><span style="color: #00C800;">Function</span> note<span style="color: #000000;">(</span>mchoice<span style="color: #000000;">)</span><br /> <span style="color: #00C800;">Local</span> mtone<br /> <span style="color: #00C800;">Local</span> mTime:= <span style="color: #000000;">23</span><br /> <span style="color: #00C800;">Do</span> <span style="color: #00C800;">case</span><br /> <span style="color: #00C800;">CASE</span> mchoice = <span style="color: #000000;">1</span><br /> mtone = <span style="color: #000000;">130.8</span><br /> <span style="color: #00C800;">CASE</span> mchoice = <span style="color: #000000;">2</span><br /> mtone = <span style="color: #000000;">138.6</span><br /> <span style="color: #00C800;">CASE</span> mchoice = <span style="color: #000000;">3</span><br /> mtone = <span style="color: #000000;">146.8</span><br /> <span style="color: #00C800;">CASE</span> mchoice = <span style="color: #000000;">4</span><br /> mtone = <span style="color: #000000;">155.6</span><br /> <span style="color: #00C800;">CASE</span> mchoice = <span style="color: #000000;">5</span><br /> mtone = <span style="color: #000000;">164.8</span><br /> <span style="color: #00C800;">CASE</span> mchoice = <span style="color: #000000;">6</span><br /> mtone = <span style="color: #000000;">174.6</span><br /> <span style="color: #00C800;">CASE</span> mchoice = <span style="color: #000000;">7</span><br /> mtone = <span style="color: #000000;">185</span><br /> <span style="color: #00C800;">CASE</span> mchoice = <span style="color: #000000;">8</span><br /> mtone = <span style="color: #000000;">196</span><br /> <span style="color: #00C800;">CASE</span> mchoice = <span style="color: #000000;">9</span><br /> mtone = <span style="color: #000000;">207.7</span><br /> <span style="color: #00C800;">CASE</span> mchoice = <span style="color: #000000;">10</span><br /> mtone = <span style="color: #000000;">220</span><br /> <span style="color: #00C800;">CASE</span> mchoice = <span style="color: #000000;">11</span><br /> mtone = <span style="color: #000000;">233.1</span><br /> <span style="color: #00C800;">CASE</span> mchoice = <span style="color: #000000;">12</span><br /> mtone = <span style="color: #000000;">246.9</span><br /><br /> <span style="color: #00C800;">Endcase</span><br /><br /><br /> tone<span style="color: #000000;">(</span>mtone,mTime<span style="color: #000000;">)</span><br /><br /><br /><br /> <span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span><br /> </div>[/code:ajdgk2r0] |
click a area of Tpanel control ( Creating a Piano) | Silvio
No entiendo lo que quieres decir
Esto funciona bien para mi
I do not understand what you mean
This works fine for me
[code=fw:1aie8qvs]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"fivewin.ch"</span><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"constant.ch"</span><br /><br />REQUEST HB_GT_GUI_DEFAULT<br /><br /><span style="color: #00C800;">function</span> Main<span style="color: #000000;">(</span><span style="color: #000000;">)</span> <span style="color: #B900B9;">//Test()</span><br /><span style="color: #00C800;">Local</span> oDlgPiano<br /><span style="color: #00C800;">Local</span> nBottom := <span style="color: #000000;">40</span> <span style="color: #B900B9;">//20</span><br /><span style="color: #00C800;">Local</span> nRight := <span style="color: #000000;">75</span> <span style="color: #B900B9;">//55</span><br /><span style="color: #00C800;">Local</span> nWidth := <span style="color: #0000ff;">Max</span><span style="color: #000000;">(</span> nRight * DLG_CHARPIX_W, <span style="color: #000000;">180</span> <span style="color: #000000;">)</span><br /><span style="color: #00C800;">Local</span> nHeight := nBottom * DLG_CHARPIX_H<br /><span style="color: #00C800;">Local</span> oBianco,oNero<br /><span style="color: #00C800;">Local</span> oBtnBianco<span style="color: #000000;">[</span><span style="color: #000000;">7</span><span style="color: #000000;">]</span><br /><span style="color: #00C800;">Local</span> oBtnNero<span style="color: #000000;">[</span><span style="color: #000000;">5</span><span style="color: #000000;">]</span><br /><span style="color: #00C800;">Local</span> oCursorBtn :=TCursor<span style="color: #000000;">(</span><span style="color: #000000;">)</span>:<span style="color: #00C800;">New</span><span style="color: #000000;">(</span>,<span style="color: #ff0000;">'HAND'</span><span style="color: #000000;">)</span><br /><span style="color: #00C800;">Local</span> nRowTastoBianco:=<span style="color: #000000;">10</span><br /><span style="color: #00C800;">Local</span> nHeightTastoBianco:=<span style="color: #000000;">100</span><br /><span style="color: #00C800;">Local</span> ncolTastoBianco:= <span style="color: #000000;">2</span><br /><span style="color: #00C800;">Local</span> nwidthTastoBianco:= <span style="color: #000000;">20</span><br /><span style="color: #00C800;">Local</span> k<br /><span style="color: #00C800;">Local</span> nHeightTastoNero:=<span style="color: #000000;">60</span><br /><span style="color: #00C800;">Local</span> ncolTastoNero:= <span style="color: #000000;">15</span><br /><span style="color: #00C800;">Local</span> nwidthTastoNero:= <span style="color: #000000;">25</span><br /><span style="color: #00C800;">Local</span> nrowTastoNero<br /><br /><br /><span style="color: #00C800;">Local</span> mTime:= <span style="color: #000000;">23</span><br /><br /> <span style="color: #0000ff;">DEFINE</span> <span style="color: #0000ff;">BRUSH</span> oBianco <span style="color: #0000ff;">COLOR</span> CLR_WHITE<br /> <span style="color: #0000ff;">DEFINE</span> <span style="color: #0000ff;">BRUSH</span> oNero <span style="color: #0000ff;">COLOR</span> CLR_BLACK<br /><br /><br /><br /> <span style="color: #0000ff;">DEFINE</span> <span style="color: #0000ff;">DIALOG</span> oDlgPiano ;<br /> <span style="color: #0000ff;">TITLE</span> i18n<span style="color: #000000;">(</span><span style="color: #ff0000;">"Virtual Piano"</span><span style="color: #000000;">)</span> ;<br /> <span style="color: #0000ff;">SIZE</span> nWidth, nHeight <span style="color: #0000ff;">PIXEL</span><br /><br /><br /><br /><br /> <span style="color: #B900B9;">//tasti bianchi</span><br /><br /> nRowTastoBianco:=<span style="color: #000000;">10</span><br /> nHeightTastoBianco:=<span style="color: #000000;">100</span><br /> ncolTastoBianco:= <span style="color: #000000;">2</span><br /> nwidthTastoBianco:= <span style="color: #000000;">20</span><br /><br /> oBtnBianco<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span>:=Tpanel<span style="color: #000000;">(</span><span style="color: #000000;">)</span>:<span style="color: #00C800;">New</span><span style="color: #000000;">(</span>nRowTastoBianco,ncolTastoBianco,nHeightTastoBianco,nwidthTastoBianco,oDlgPiano<span style="color: #000000;">)</span><br /> oBtnBianco<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span>:<span style="color: #000000;">oBrush</span>:= oBianco<br /> oBtnBianco<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span>:<span style="color: #000000;">bLClicked</span> := <span style="color: #000000;">{</span> | x, y, z | Note<span style="color: #000000;">(</span>x,y,z,<span style="color: #000000;">1</span><span style="color: #000000;">)</span> <span style="color: #000000;">}</span><br /> <span style="color: #B900B9;">//oBtnBianco[1]:oCursor:=oCursorBtn</span><br /> <span style="color: #B900B9;">//oBtnBianco[1]:bMMoved = { | nRow, nCol | oBtnNero[1]:Disable() }</span><br /><br /> ncolTastoBianco:=oBtnBianco<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span>:<span style="color: #000000;">nRight</span><span style="color: #000000;">+2</span><br /> nwidthTastoBianco+= <span style="color: #000000;">20</span><br /><br /> oBtnBianco<span style="color: #000000;">[</span><span style="color: #000000;">2</span><span style="color: #000000;">]</span>:=Tpanel<span style="color: #000000;">(</span><span style="color: #000000;">)</span>:<span style="color: #00C800;">New</span><span style="color: #000000;">(</span>nRowTastoBianco,ncolTastoBianco,nHeightTastoBianco,nwidthTastoBianco,oDlgPiano<span style="color: #000000;">)</span><br /> oBtnBianco<span style="color: #000000;">[</span><span style="color: #000000;">2</span><span style="color: #000000;">]</span>:<span style="color: #000000;">oBrush</span>:= oBianco<br /> oBtnBianco<span style="color: #000000;">[</span><span style="color: #000000;">2</span><span style="color: #000000;">]</span>:<span style="color: #000000;">bLClicked</span> := <span style="color: #000000;">{</span> | x, y, z | Note<span style="color: #000000;">(</span>x,y,z,<span style="color: #000000;">3</span><span style="color: #000000;">)</span> <span style="color: #000000;">}</span><br /> <span style="color: #B900B9;">//oBtnBianco[2]:oCursor:=oCursorBtn</span><br /><br /> nRowTastoNero:=<span style="color: #000000;">10</span><br /> nHeightTastoNero:=<span style="color: #000000;">60</span><br /> ncolTastoNero:= <span style="color: #000000;">15</span><br /> nwidthTastoNero:= <span style="color: #000000;">25</span><br /><br /><br /> oBtnNero<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span>:=Tpanel<span style="color: #000000;">(</span><span style="color: #000000;">)</span>:<span style="color: #00C800;">New</span><span style="color: #000000;">(</span>nRowTastoNero,ncolTastoNero,nHeightTastoNero,nwidthTastoNero,oDlgPiano<span style="color: #000000;">)</span><br /> oBtnNero<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span>:<span style="color: #000000;">bLClicked</span> := <span style="color: #000000;">{</span> | x, y, z | Note<span style="color: #000000;">(</span>x,y,z,<span style="color: #000000;">2</span><span style="color: #000000;">)</span> <span style="color: #000000;">}</span><br /> <span style="color: #B900B9;">//oBtnNero[1]:oCursor:=oCursorBtn</span><br /> <span style="color: #B900B9;">//oBtnNero[1]:bMMoved = { | nRow, nCol | oBtnBianco[1]:Disable(),oBtnBianco[2]:Disable() }</span><br /><br /> <span style="color: #00C800;">for</span> k= <span style="color: #000000;">1</span> <span style="color: #0000ff;">to</span> <span style="color: #000000;">1</span><br /> oBtnNero<span style="color: #000000;">[</span>k<span style="color: #000000;">]</span>:<span style="color: #000000;">oBrush</span>:= oNero<br /> <span style="color: #00C800;">next</span><br /><br /> <span style="color: #0000ff;">ACTIVATE</span> <span style="color: #0000ff;">DIALOG</span> oDlgPiano<br /> RETUR <span style="color: #00C800;">NIL</span><br /><br /><br /><span style="color: #00C800;">Function</span> note<span style="color: #000000;">(</span>x,y,z,mchoice<span style="color: #000000;">)</span><br /> <span style="color: #00C800;">Local</span> mtone<br /> <span style="color: #00C800;">Local</span> mTime:= <span style="color: #000000;">0.23</span><br /> <span style="color: #00C800;">Do</span> <span style="color: #00C800;">case</span><br /> <span style="color: #00C800;">CASE</span> mchoice = <span style="color: #000000;">1</span><br /> mtone = <span style="color: #000000;">130.8</span><br /> ? <span style="color: #000000;">1</span><br /> <span style="color: #00C800;">CASE</span> mchoice = <span style="color: #000000;">2</span><br /> mtone = <span style="color: #000000;">138.6</span><br /> ? <span style="color: #000000;">2</span><br /> <span style="color: #00C800;">CASE</span> mchoice = <span style="color: #000000;">3</span><br /> mtone = <span style="color: #000000;">146.8</span><br /> ? <span style="color: #000000;">3</span><br /> <span style="color: #00C800;">CASE</span> mchoice = <span style="color: #000000;">4</span><br /> mtone = <span style="color: #000000;">155.6</span><br /> <span style="color: #00C800;">CASE</span> mchoice = <span style="color: #000000;">5</span><br /> mtone = <span style="color: #000000;">164.8</span><br /> <span style="color: #00C800;">CASE</span> mchoice = <span style="color: #000000;">6</span><br /> mtone = <span style="color: #000000;">174.6</span><br /> <span style="color: #00C800;">CASE</span> mchoice = <span style="color: #000000;">7</span><br /> mtone = <span style="color: #000000;">185</span><br /> <span style="color: #00C800;">CASE</span> mchoice = <span style="color: #000000;">8</span><br /> mtone = <span style="color: #000000;">196</span><br /> <span style="color: #00C800;">CASE</span> mchoice = <span style="color: #000000;">9</span><br /> mtone = <span style="color: #000000;">207.7</span><br /> <span style="color: #00C800;">CASE</span> mchoice = <span style="color: #000000;">10</span><br /> mtone = <span style="color: #000000;">220</span><br /> <span style="color: #00C800;">CASE</span> mchoice = <span style="color: #000000;">11</span><br /> mtone = <span style="color: #000000;">233.1</span><br /> <span style="color: #00C800;">CASE</span> mchoice = <span style="color: #000000;">12</span><br /> mtone = <span style="color: #000000;">246.9</span><br /><br /> <span style="color: #00C800;">Endcase</span><br /><br /><br /> tone<span style="color: #000000;">(</span>mtone, mTime<span style="color: #000000;">)</span><br /><br /><br /><br /> <span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span><br /> <br /> </div>[/code:1aie8qvs] |
click a area of Tpanel control ( Creating a Piano) | Dear cNavarro,
If you press the first white panel it play the note C and the msginfo is 1
If you press the black panel on area is on first white panel it play the note C and the msginfo is 1 but it is wrong because it must play c# and the msginfo must be = 2
If you press the black panel on area is on second white panel it play the note D and the msginfo is 3 but it is wrong because it must play c# and the msginfo must be = 2
Dear Antonio,
I saw there is a function [b:7996ifas]PtInRect( )[/b:7996ifas] , it could be usefull to click on right coordinates ...
can you make a sample or where I can see a small sample with this function ? |
click a area of Tpanel control ( Creating a Piano) | Silvio,
In FWH\source\classes\vistamnu.prg there is an example of use |
click a area of Tpanel control ( Creating a Piano) | Silvio
Please try this Piano.Prg
[code=fw:zjibu3rx]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #B900B9;">/*<br />*<br />* Piano.prg<br />* G.N.Rao<br />*<br />*/</span><br /><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"fiveWin.Ch"</span><br /><br /><span style="color: #00C800;">Static</span> aTone := <span style="color: #000000;">{</span> <span style="color: #000000;">130.8</span>, <span style="color: #000000;">138.6</span>, <span style="color: #000000;">146.8</span>, <span style="color: #000000;">155.6</span>, <span style="color: #000000;">164.8</span>, <span style="color: #000000;">174.6</span>, <span style="color: #000000;">185</span>, <span style="color: #000000;">196</span>, <span style="color: #000000;">207.7</span>, <span style="color: #000000;">220</span>, <span style="color: #000000;">233.1</span>, <span style="color: #000000;">246.9</span> <span style="color: #000000;">}</span><br /><span style="color: #00C800;">static</span> aWhite, aBlack<br /><br /><span style="color: #B900B9;">// Configuration Parameters</span><br /><span style="color: #00C800;">static</span> aDlgMargin := <span style="color: #000000;">{</span> <span style="color: #000000;">20</span>, <span style="color: #000000;">20</span>, <span style="color: #000000;">20</span>, <span style="color: #000000;">20</span> <span style="color: #000000;">}</span> <span style="color: #B900B9;">// top, left, bottom, right</span><br /><span style="color: #00C800;">static</span> nHtWhite := <span style="color: #000000;">200</span><br /><span style="color: #00C800;">static</span> nWdWhite := <span style="color: #000000;">40</span><br /><span style="color: #00C800;">static</span> nHtBlack := <span style="color: #000000;">120</span><br /><span style="color: #00C800;">static</span> nWdBlack := <span style="color: #000000;">20</span><br /><span style="color: #00C800;">static</span> nDuration := <span style="color: #000000;">23</span><br /><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br /><span style="color: #00C800;">function</span> Main<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> <span style="color: #00C800;">local</span> oDlg<br /><br /> PrepareKeys<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> <span style="color: #0000ff;">DEFINE</span> <span style="color: #0000ff;">DIALOG</span> oDlg <span style="color: #0000ff;">SIZE</span> ;<br /> aWhite<span style="color: #000000;">[</span><span style="color: #000000;">7</span><span style="color: #000000;">]</span><span style="color: #000000;">[</span><span style="color: #000000;">3</span><span style="color: #000000;">]</span><span style="color: #000000;">[</span><span style="color: #000000;">4</span><span style="color: #000000;">]</span>+aDlgMargin<span style="color: #000000;">[</span> <span style="color: #000000;">4</span> <span style="color: #000000;">]</span>, aWhite<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span><span style="color: #000000;">[</span><span style="color: #000000;">3</span><span style="color: #000000;">]</span><span style="color: #000000;">[</span><span style="color: #000000;">3</span><span style="color: #000000;">]</span>+aDlgMargin<span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span> ;<br /> <span style="color: #0000ff;">PIXEL</span> <span style="color: #0000ff;">COLOR</span> CLR_BLACK, CLR_HGRAY <span style="color: #0000ff;">TITLE</span> <span style="color: #ff0000;">"PIANO"</span><br /><br /> <span style="color: #0000ff;">ACTIVATE</span> <span style="color: #0000ff;">DIALOG</span> oDlg <span style="color: #0000ff;">CENTERED</span> ;<br /> <span style="color: #0000ff;">ON</span> <span style="color: #0000ff;">PAINT</span> PaintPiano<span style="color: #000000;">(</span> hDC, oDlg <span style="color: #000000;">)</span> ;<br /> <span style="color: #0000ff;">ON</span> <span style="color: #0000ff;">CLICK</span> PlayPiano<span style="color: #000000;">(</span> nRow, nCol <span style="color: #000000;">)</span><br /><br /><span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span><br /><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br /><span style="color: #00C800;">static</span> <span style="color: #00C800;">function</span> PaintPiano<span style="color: #000000;">(</span> hDC, oDlg <span style="color: #000000;">)</span><br /><br /> <span style="color: #00C800;">local</span> hBrush<br /> <span style="color: #00C800;">local</span> aKey<br /><br /> hBrush := CreateSolidBrush<span style="color: #000000;">(</span> CLR_WHITE <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">for</span> each aKey in aWhite<br /> FillRect<span style="color: #000000;">(</span> hDC, aKey<span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span>, hBrush <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">next</span><br /> DeleteObject<span style="color: #000000;">(</span> hBrush <span style="color: #000000;">)</span><br /><br /> hBrush := CreateSolidBrush<span style="color: #000000;">(</span> CLR_BLACK <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">for</span> each aKey in aBlack<br /> FillRect<span style="color: #000000;">(</span> hDC, aKey<span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span>, hBrush <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">next</span><br /> DeleteObject<span style="color: #000000;">(</span> hBrush <span style="color: #000000;">)</span><br /><br /><span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span><br /><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br /><span style="color: #00C800;">static</span> <span style="color: #00C800;">function</span> PlayPiano<span style="color: #000000;">(</span> nRow, nCol <span style="color: #000000;">)</span><br /><br /> <span style="color: #00C800;">local</span> n, aKey<br /><br /> <span style="color: #00C800;">for</span> each aKey in <span style="color: #000000;">{</span> aBlack, aWhite <span style="color: #000000;">}</span><br /> <span style="color: #00C800;">if</span> nRow >= aKey<span style="color: #000000;">[</span> <span style="color: #000000;">1</span> <span style="color: #000000;">]</span><span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span><span style="color: #000000;">[</span> <span style="color: #000000;">1</span> <span style="color: #000000;">]</span> .and. nRow < aKey<span style="color: #000000;">[</span> <span style="color: #000000;">1</span> <span style="color: #000000;">]</span><span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span><span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span><br /> <span style="color: #00C800;">for</span> n := <span style="color: #000000;">1</span> <span style="color: #0000ff;">to</span> Len<span style="color: #000000;">(</span> aKey <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">if</span> nCol >= aKey<span style="color: #000000;">[</span> n <span style="color: #000000;">]</span><span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span><span style="color: #000000;">[</span> <span style="color: #000000;">2</span> <span style="color: #000000;">]</span><br /> <span style="color: #00C800;">if</span> nCol < aKey<span style="color: #000000;">[</span> n <span style="color: #000000;">]</span><span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span><span style="color: #000000;">[</span> <span style="color: #000000;">4</span> <span style="color: #000000;">]</span><br /> TONE<span style="color: #000000;">(</span> aKey<span style="color: #000000;">[</span> n <span style="color: #000000;">]</span><span style="color: #000000;">[</span> <span style="color: #000000;">2</span> <span style="color: #000000;">]</span>, <span style="color: #000000;">23</span> <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span><br /> <span style="color: #00C800;">endif</span><br /> <span style="color: #00C800;">else</span><br /> EXIT<br /> <span style="color: #00C800;">endif</span><br /> <span style="color: #00C800;">next</span><br /> <span style="color: #00C800;">endif</span><br /> <span style="color: #00C800;">next</span><br /><br /><span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span><br /><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br /><span style="color: #00C800;">static</span> <span style="color: #00C800;">function</span> PrepareKeys<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> <span style="color: #00C800;">local</span> nGap := <span style="color: #000000;">4</span><br /> <span style="color: #00C800;">local</span> n, nTop, nLeft, nBottom<br /><br /> aWhite := <span style="color: #000000;">{</span><span style="color: #000000;">}</span><br /> nTop := aDlgMargin<span style="color: #000000;">[</span> <span style="color: #000000;">1</span> <span style="color: #000000;">]</span><br /> nLeft := aDlgMargin<span style="color: #000000;">[</span> <span style="color: #000000;">2</span> <span style="color: #000000;">]</span><br /> nBottom := nTop + nHtWhite<br /><br /> <span style="color: #00C800;">for</span> each n in <span style="color: #000000;">{</span> <span style="color: #000000;">1</span>, <span style="color: #000000;">3</span>, <span style="color: #000000;">5</span>, <span style="color: #000000;">6</span>, <span style="color: #000000;">8</span>, <span style="color: #000000;">10</span>, <span style="color: #000000;">12</span> <span style="color: #000000;">}</span><br /> AAdd<span style="color: #000000;">(</span> aWhite, <span style="color: #000000;">{</span> n, aTone<span style="color: #000000;">[</span> n <span style="color: #000000;">]</span>, <span style="color: #000000;">{</span> nTop, nLeft, nBottom, nLeft + nWdWhite <span style="color: #000000;">}</span> <span style="color: #000000;">}</span> <span style="color: #000000;">)</span><br /> nLeft += <span style="color: #000000;">(</span> nWdWhite + nGap <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">next</span><br /><br /> aBlack := <span style="color: #000000;">{</span><span style="color: #000000;">}</span><br /> nLeft := aDlgMargin<span style="color: #000000;">[</span> <span style="color: #000000;">2</span> <span style="color: #000000;">]</span> + nWdWhite - Int<span style="color: #000000;">(</span> nWdBlack / <span style="color: #000000;">2</span> <span style="color: #000000;">)</span><br /> nBottom := nTop + nHtBlack<br /><br /> <span style="color: #00C800;">for</span> each n in <span style="color: #000000;">{</span> <span style="color: #000000;">2</span>, <span style="color: #000000;">4</span>, <span style="color: #000000;">7</span>, <span style="color: #000000;">9</span>, <span style="color: #000000;">11</span> <span style="color: #000000;">}</span><br /> AAdd<span style="color: #000000;">(</span> aBlack, <span style="color: #000000;">{</span> n, aTone<span style="color: #000000;">[</span> n <span style="color: #000000;">]</span>, <span style="color: #000000;">{</span> nTop, nLeft, nBottom, nLeft + nWdBlack <span style="color: #000000;">}</span> <span style="color: #000000;">}</span> <span style="color: #000000;">)</span><br /> nLeft += <span style="color: #000000;">(</span> nWdWhite + nGap <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">if</span> n == <span style="color: #000000;">4</span><br /> nLeft += <span style="color: #000000;">(</span> nWdWhite + nGap <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">endif</span><br /> <span style="color: #00C800;">next</span><br /><br /><span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span><br /><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /> </div>[/code:zjibu3rx] |
click a area of Tpanel control ( Creating a Piano) | ,. |
click a area of Tpanel control ( Creating a Piano) | for write the note ...I'm trying with
[code=fw:1clatkar]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><br /><span style="color: #00D7D7;">#define</span> SRCCOPY <span style="color: #000000;">13369376</span><br /><span style="color: #00D7D7;">#define</span> DT_TOP 0x00000000<br /><span style="color: #00D7D7;">#define</span> DT_LEFT 0x00000000<br /><span style="color: #00D7D7;">#define</span> DT_CENTER 0x00000001<br /><span style="color: #00D7D7;">#define</span> DT_RIGHT 0x00000002<br /><span style="color: #00D7D7;">#define</span> DT_VCENTER 0x00000004<br /><span style="color: #00D7D7;">#define</span> DT_BOTTOM 0x00000008<br /><span style="color: #00D7D7;">#define</span> DT_WORDBREAK 0x00000010<br /><span style="color: #00D7D7;">#define</span> DT_SINGLELINE 0x00000020<br /><span style="color: #00D7D7;">#define</span> DT_EXPANDTABS 0x00000040<br /><span style="color: #00D7D7;">#define</span> DT_TABSTOP 0x00000080<br /><span style="color: #00D7D7;">#define</span> DT_NOCLIP 0x00000100<br /><span style="color: #00D7D7;">#define</span> DT_EXTERNALLEADING 0x00000200<br /><span style="color: #00D7D7;">#define</span> DT_CALCRECT 0x00000400<br /><span style="color: #00D7D7;">#define</span> DT_NOPREFIX 0x00000800<br /><span style="color: #00D7D7;">#define</span> DT_INTERNAL 0x00001000<br /><br /> <span style="color: #0000ff;">DEFINE</span> <span style="color: #0000ff;">FONT</span> oFont <span style="color: #0000ff;">NAME</span> GetSysFont<span style="color: #000000;">(</span><span style="color: #000000;">)</span> <span style="color: #0000ff;">SIZE</span> <span style="color: #000000;">0</span>, <span style="color: #000000;">-9</span> bold<br /><br /><span style="color: #0000ff;">DEFINE</span> <span style="color: #0000ff;">DIALOG</span> oDlg <span style="color: #0000ff;">SIZE</span> ;<br /> aWhite<span style="color: #000000;">[</span><span style="color: #000000;">7</span><span style="color: #000000;">]</span><span style="color: #000000;">[</span><span style="color: #000000;">3</span><span style="color: #000000;">]</span><span style="color: #000000;">[</span><span style="color: #000000;">4</span><span style="color: #000000;">]</span>+aDlgMargin<span style="color: #000000;">[</span> <span style="color: #000000;">4</span> <span style="color: #000000;">]</span>, aWhite<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span><span style="color: #000000;">[</span><span style="color: #000000;">3</span><span style="color: #000000;">]</span><span style="color: #000000;">[</span><span style="color: #000000;">3</span><span style="color: #000000;">]</span>+aDlgMargin<span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span> ;<br /> <span style="color: #0000ff;">PIXEL</span> <span style="color: #0000ff;">COLOR</span> CLR_BLACK, CLR_HGRAY <span style="color: #0000ff;">TITLE</span> <span style="color: #ff0000;">"PIANO"</span> <span style="color: #000000;">[</span>b<span style="color: #000000;">]</span><span style="color: #0000ff;">FONT</span> oFont<span style="color: #000000;">[</span>/b<span style="color: #000000;">]</span><br /><br /><br /><br /><span style="color: #00C800;">static</span> <span style="color: #00C800;">function</span> PaintPiano<span style="color: #000000;">(</span> hDC, oDlg <span style="color: #000000;">)</span><br /><br /> <span style="color: #00C800;">local</span> hBrush<br /> <span style="color: #00C800;">local</span> aKey<br /> <span style="color: #00C800;">local</span> aWhite_Text := <span style="color: #000000;">{</span><span style="color: #ff0000;">"C"</span>,<span style="color: #ff0000;">"D"</span>,<span style="color: #ff0000;">"E"</span>,<span style="color: #ff0000;">"F"</span>,<span style="color: #ff0000;">"G"</span>,<span style="color: #ff0000;">"A"</span>,<span style="color: #ff0000;">"B"</span> <span style="color: #000000;">}</span><br /> <span style="color: #00C800;">local</span> aBlack_Text := <span style="color: #000000;">{</span><span style="color: #ff0000;">"C#"</span>,<span style="color: #ff0000;">"D#"</span>,<span style="color: #ff0000;">"F#"</span>,<span style="color: #ff0000;">"G#"</span>,<span style="color: #ff0000;">"A#"</span><span style="color: #000000;">}</span><br /><br /><br /> n:= <span style="color: #000000;">1</span><br /> hBrush := CreateSolidBrush<span style="color: #000000;">(</span> CLR_WHITE <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">for</span> each aKey in aWhite<br /> FillRect<span style="color: #000000;">(</span> hDC, aKey<span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span>, hBrush <span style="color: #000000;">)</span><br /> nMode := SetBkMode<span style="color: #000000;">(</span> hDC, <span style="color: #000000;">1</span> <span style="color: #000000;">)</span><br /> nColor := SetTextColor<span style="color: #000000;">(</span> hDC, CLR_BLACK <span style="color: #000000;">)</span><br /> hFont := <span style="color: #00C800;">if</span><span style="color: #000000;">(</span>oDlg:<span style="color: #000000;">oFont</span> != <span style="color: #00C800;">nil</span>,oDlg:<span style="color: #000000;">oFont</span>:<span style="color: #000000;">hFont</span>, GetDefFont<span style="color: #000000;">(</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span><br /> hOldFont := SelectObject<span style="color: #000000;">(</span> hDC, hFont <span style="color: #000000;">)</span><br /> DrawText<span style="color: #000000;">(</span> hDC, aWhite_Text<span style="color: #000000;">[</span>n<span style="color: #000000;">]</span> ,aKey<span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span> , nOr<span style="color: #000000;">(</span> DT_SINGLELINE, DT_VCENTER, DT_RIGHT <span style="color: #000000;">)</span><span style="color: #000000;">)</span><br /> SetBkMode<span style="color: #000000;">(</span> hDC, nMode <span style="color: #000000;">)</span><br /> n:= n<span style="color: #000000;">+1</span><br /> <span style="color: #00C800;">next</span><br /> DeleteObject<span style="color: #000000;">(</span> hBrush <span style="color: #000000;">)</span><br /><br /><br /> n:= <span style="color: #000000;">1</span><br /> hBrush := CreateSolidBrush<span style="color: #000000;">(</span> CLR_BLACK <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">for</span> each aKey in aBlack<br /> FillRect<span style="color: #000000;">(</span> hDC, aKey<span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span>, hBrush <span style="color: #000000;">)</span><br /> nMode := SetBkMode<span style="color: #000000;">(</span> hDC, <span style="color: #000000;">1</span> <span style="color: #000000;">)</span><br /> nColor := SetTextColor<span style="color: #000000;">(</span> hDC, CLR_YELLOW <span style="color: #000000;">)</span><br /> hFont := <span style="color: #00C800;">if</span><span style="color: #000000;">(</span>oDlg:<span style="color: #000000;">oFont</span> != <span style="color: #00C800;">nil</span>,oDlg:<span style="color: #000000;">oFont</span>:<span style="color: #000000;">hFont</span>, GetDefFont<span style="color: #000000;">(</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span><br /> hOldFont := SelectObject<span style="color: #000000;">(</span> hDC, hFont <span style="color: #000000;">)</span><br /> DrawText<span style="color: #000000;">(</span> hDC, aBlack_Text<span style="color: #000000;">[</span>n<span style="color: #000000;">]</span> ,aKey<span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span> , nOr<span style="color: #000000;">(</span> DT_SINGLELINE, DT_VCENTER, DT_RIGHT <span style="color: #000000;">)</span><span style="color: #000000;">)</span><br /> SetBkMode<span style="color: #000000;">(</span> hDC, nMode <span style="color: #000000;">)</span><br /> n:= n<span style="color: #000000;">+1</span><br /> <span style="color: #00C800;">next</span><br /> DeleteObject<span style="color: #000000;">(</span> hBrush <span style="color: #000000;">)</span><br /><br /><br /><span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span><br /><br /> </div>[/code:1clatkar]
[b:1clatkar]the result [/b:1clatkar]
[img:1clatkar]http://www.eoeo.it/wp-content/uploads/2014/12/piano.jpg[/img:1clatkar]
How I can move the text on white keys ? |
click a area of Tpanel control ( Creating a Piano) | Found !!!!
aKey[ 3 ][1]+= 80
aKey[ 3 ][2]+= 20
[b:35xj18ye]the result [/b:35xj18ye]
[img:35xj18ye]http://www.eoeo.it/wp-content/uploads/2014/12/piano2.jpg[/img:35xj18ye]
[code=fw:35xj18ye]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #00C800;">static</span> <span style="color: #00C800;">function</span> PaintPiano<span style="color: #000000;">(</span> hDC, oDlg <span style="color: #000000;">)</span><br /><br /> <span style="color: #00C800;">local</span> hBrush<br /> <span style="color: #00C800;">local</span> aKey<br /> <span style="color: #00C800;">local</span> aWhite_Text := <span style="color: #000000;">{</span><span style="color: #ff0000;">"C"</span>,<span style="color: #ff0000;">"D"</span>,<span style="color: #ff0000;">"E"</span>,<span style="color: #ff0000;">"F"</span>,<span style="color: #ff0000;">"G"</span>,<span style="color: #ff0000;">"A"</span>,<span style="color: #ff0000;">"B"</span> <span style="color: #000000;">}</span><br /> <span style="color: #00C800;">local</span> aBlack_Text := <span style="color: #000000;">{</span><span style="color: #ff0000;">"C#"</span>,<span style="color: #ff0000;">"D#"</span>,<span style="color: #ff0000;">"F#"</span>,<span style="color: #ff0000;">"G#"</span>,<span style="color: #ff0000;">"A#"</span><span style="color: #000000;">}</span><br /><br /><br /> n:= <span style="color: #000000;">1</span><br /> hBrush := CreateSolidBrush<span style="color: #000000;">(</span> CLR_WHITE <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">for</span> each aKey in aWhite<br /> FillRect<span style="color: #000000;">(</span> hDC, aKey<span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span>, hBrush <span style="color: #000000;">)</span><br /> nMode := SetBkMode<span style="color: #000000;">(</span> hDC, <span style="color: #000000;">1</span> <span style="color: #000000;">)</span><br /> nColor := SetTextColor<span style="color: #000000;">(</span> hDC, CLR_BLACK <span style="color: #000000;">)</span><br /> hFont := <span style="color: #00C800;">if</span><span style="color: #000000;">(</span>oDlg:<span style="color: #000000;">oFont</span> != <span style="color: #00C800;">nil</span>,oDlg:<span style="color: #000000;">oFont</span>:<span style="color: #000000;">hFont</span>, GetDefFont<span style="color: #000000;">(</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span><br /> hOldFont := SelectObject<span style="color: #000000;">(</span> hDC, hFont <span style="color: #000000;">)</span><br /> aKey<span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span><span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span>+= <span style="color: #000000;">80</span><br /> aKey<span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span><span style="color: #000000;">[</span><span style="color: #000000;">2</span><span style="color: #000000;">]</span>+= <span style="color: #000000;">20</span><br /> DrawText<span style="color: #000000;">(</span> hDC, aWhite_Text<span style="color: #000000;">[</span>n<span style="color: #000000;">]</span> ,aKey<span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span> , nOr<span style="color: #000000;">(</span> DT_SINGLELINE,DT_VCENTER,DT_VCENTER <span style="color: #000000;">)</span><span style="color: #000000;">)</span><br /> SetBkMode<span style="color: #000000;">(</span> hDC, nMode <span style="color: #000000;">)</span><br /> n:= n<span style="color: #000000;">+1</span><br /> aKey<span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span><span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span>-= <span style="color: #000000;">80</span><br /> aKey<span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span><span style="color: #000000;">[</span><span style="color: #000000;">2</span><span style="color: #000000;">]</span>-= <span style="color: #000000;">20</span><br /> <span style="color: #00C800;">next</span><br /> DeleteObject<span style="color: #000000;">(</span> hBrush <span style="color: #000000;">)</span><br /><br /><br /> n:= <span style="color: #000000;">1</span><br /> hBrush := CreateSolidBrush<span style="color: #000000;">(</span> CLR_BLACK <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">for</span> each aKey in aBlack<br /> FillRect<span style="color: #000000;">(</span> hDC, aKey<span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span>, hBrush <span style="color: #000000;">)</span><br /> nMode := SetBkMode<span style="color: #000000;">(</span> hDC, <span style="color: #000000;">1</span> <span style="color: #000000;">)</span><br /> nColor := SetTextColor<span style="color: #000000;">(</span> hDC, CLR_YELLOW <span style="color: #000000;">)</span><br /> hFont := <span style="color: #00C800;">if</span><span style="color: #000000;">(</span>oDlg:<span style="color: #000000;">oFont</span> != <span style="color: #00C800;">nil</span>,oDlg:<span style="color: #000000;">oFont</span>:<span style="color: #000000;">hFont</span>, GetDefFont<span style="color: #000000;">(</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span><br /> hOldFont := SelectObject<span style="color: #000000;">(</span> hDC, hFont <span style="color: #000000;">)</span><br /> DrawText<span style="color: #000000;">(</span> hDC, aBlack_Text<span style="color: #000000;">[</span>n<span style="color: #000000;">]</span> ,aKey<span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span> , nOr<span style="color: #000000;">(</span> DT_SINGLELINE, DT_VCENTER, DT_RIGHT <span style="color: #000000;">)</span><span style="color: #000000;">)</span><br /> SetBkMode<span style="color: #000000;">(</span> hDC, nMode <span style="color: #000000;">)</span><br /> n:= n<span style="color: #000000;">+1</span><br /><br /><br /> <span style="color: #00C800;">next</span><br /> DeleteObject<span style="color: #000000;">(</span> hBrush <span style="color: #000000;">)</span><br /><br /><br /><span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span></div>[/code:35xj18ye] |
click a area of Tpanel control ( Creating a Piano) | . |
click a area of Tpanel control ( Creating a Piano) | Rao, Silvio,
Very nice <!-- s:-) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":-)" title="Smile" /><!-- s:-) --> |
click a area of Tpanel control ( Creating a Piano) | Please try this with #define METHOD1 and also commenting out //#define METHOD1.
Are you sure the frequencies are right?
Is it possible to stop the Tone when the user presses another key?
[code=fw:3itj5sj7]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #B900B9;">/*<br />*<br />* Piano.prg<br />* G.N.Rao<br />*<br />*/</span><br /><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"fiveWin.Ch"</span><br /><br /><span style="color: #00D7D7;">#define</span> METHOD1<br /><br />#ifdef METHOD1<br /><span style="color: #00C800;">static</span> aTone := <span style="color: #000000;">{</span> <span style="color: #000000;">130.8</span>, <span style="color: #000000;">138.6</span>, <span style="color: #000000;">146.8</span>, <span style="color: #000000;">155.6</span>, <span style="color: #000000;">164.8</span>, <span style="color: #000000;">174.6</span>, <span style="color: #000000;">185</span>, <span style="color: #000000;">196</span>, <span style="color: #000000;">207.7</span>, <span style="color: #000000;">220</span>, <span style="color: #000000;">233.1</span>, <span style="color: #000000;">246.9</span>,;<br /> <span style="color: #000000;">261.7</span>, <span style="color: #000000;">277.2</span>, <span style="color: #000000;">293.7</span>, <span style="color: #000000;">311.1</span>, <span style="color: #000000;">329.6</span>,<span style="color: #000000;">349.2</span>,<span style="color: #000000;">370</span>, <span style="color: #000000;">415.3</span>, <span style="color: #000000;">440</span>, <span style="color: #000000;">466.2</span>, <span style="color: #000000;">493.9</span>, <span style="color: #000000;">523.3</span> <span style="color: #000000;">}</span><br />#else<br /><span style="color: #00C800;">static</span> aTone := <span style="color: #000000;">{</span> <span style="color: #000000;">262</span>, <span style="color: #000000;">277</span>, <span style="color: #000000;">294</span>, <span style="color: #000000;">311</span>, <span style="color: #000000;">330</span>, <span style="color: #000000;">349</span>, <span style="color: #000000;">370</span>, <span style="color: #000000;">392</span>, <span style="color: #000000;">415</span>, <span style="color: #000000;">440</span>, <span style="color: #000000;">460</span>, <span style="color: #000000;">494</span>, ;<br /> <span style="color: #000000;">523</span>, <span style="color: #000000;">554</span>, <span style="color: #000000;">587</span>, <span style="color: #000000;">622</span>, <span style="color: #000000;">659</span>, <span style="color: #000000;">698</span>, <span style="color: #000000;">740</span>, <span style="color: #000000;">784</span>, <span style="color: #000000;">831</span>, <span style="color: #000000;">880</span>, <span style="color: #000000;">932</span>, <span style="color: #000000;">988</span>, ;<br /> <span style="color: #000000;">1047</span>,<span style="color: #000000;">1109</span>,<span style="color: #000000;">1175</span>,<span style="color: #000000;">1244</span>,<span style="color: #000000;">1318</span>,<span style="color: #000000;">1397</span>,<span style="color: #000000;">1480</span>,<span style="color: #000000;">1568</span>,<span style="color: #000000;">1661</span>,<span style="color: #000000;">1760</span>,<span style="color: #000000;">1865</span>,<span style="color: #000000;">1976</span>, ;<br /> <span style="color: #000000;">2094</span>,<span style="color: #000000;">2218</span>,<span style="color: #000000;">2350</span>,<span style="color: #000000;">2489</span>,<span style="color: #000000;">2637</span>,<span style="color: #000000;">2794</span>,<span style="color: #000000;">2960</span>,<span style="color: #000000;">3136</span>,<span style="color: #000000;">3322</span>,<span style="color: #000000;">3520</span>,<span style="color: #000000;">3730</span>,<span style="color: #000000;">3951</span>, ;<br /> <span style="color: #000000;">4187</span> <span style="color: #000000;">}</span><br />#endif<br /><br /><span style="color: #00C800;">static</span> aWhite, aBlack<br /><br /><span style="color: #B900B9;">// Configuration Parameters</span><br /><span style="color: #00C800;">static</span> aDlgMargin := <span style="color: #000000;">{</span> <span style="color: #000000;">20</span>, <span style="color: #000000;">20</span>, <span style="color: #000000;">20</span>, <span style="color: #000000;">20</span> <span style="color: #000000;">}</span> <span style="color: #B900B9;">// top, left, bottom, right</span><br /><span style="color: #00C800;">static</span> nHtWhite := <span style="color: #000000;">200</span><br /><span style="color: #00C800;">static</span> nWdWhite := <span style="color: #000000;">40</span><br /><span style="color: #00C800;">static</span> nHtBlack := <span style="color: #000000;">120</span><br /><span style="color: #00C800;">static</span> nWdBlack := <span style="color: #000000;">20</span><br /><span style="color: #00C800;">static</span> nDuration := <span style="color: #000000;">23</span><br /><span style="color: #00C800;">static</span> nKeyPress := <span style="color: #000000;">0</span><br /><span style="color: #00C800;">static</span> nOctaves := <span style="color: #000000;">4</span><br /><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br /><span style="color: #00C800;">function</span> Main<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> <span style="color: #00C800;">local</span> oDlg, oFont<br /><br /> nOctaves := <span style="color: #0000ff;">Min</span><span style="color: #000000;">(</span> nOctaves, Int<span style="color: #000000;">(</span> Len<span style="color: #000000;">(</span> aTone <span style="color: #000000;">)</span> / <span style="color: #000000;">12</span> <span style="color: #000000;">)</span> <span style="color: #000000;">)</span><br /> PrepareKeys<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> <span style="color: #0000ff;">DEFINE</span> <span style="color: #0000ff;">FONT</span> oFont <span style="color: #0000ff;">NAME</span> <span style="color: #ff0000;">"TAHOMA"</span> <span style="color: #0000ff;">SIZE</span> <span style="color: #000000;">0</span>,<span style="color: #000000;">-10</span> BOLD<br /> <span style="color: #0000ff;">DEFINE</span> <span style="color: #0000ff;">DIALOG</span> oDlg <span style="color: #0000ff;">FONT</span> oFont <span style="color: #0000ff;">SIZE</span> ;<br /> ATail<span style="color: #000000;">(</span> aWhite <span style="color: #000000;">)</span><span style="color: #000000;">[</span><span style="color: #000000;">3</span><span style="color: #000000;">]</span><span style="color: #000000;">[</span><span style="color: #000000;">4</span><span style="color: #000000;">]</span>+aDlgMargin<span style="color: #000000;">[</span> <span style="color: #000000;">4</span> <span style="color: #000000;">]</span>, aWhite<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span><span style="color: #000000;">[</span><span style="color: #000000;">3</span><span style="color: #000000;">]</span><span style="color: #000000;">[</span><span style="color: #000000;">3</span><span style="color: #000000;">]</span>+aDlgMargin<span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span> ;<br /> <span style="color: #0000ff;">PIXEL</span> <span style="color: #0000ff;">COLOR</span> CLR_BLACK, CLR_HGRAY <span style="color: #0000ff;">TITLE</span> <span style="color: #ff0000;">"PIANO"</span><br /><br /> <span style="color: #0000ff;">ACTIVATE</span> <span style="color: #0000ff;">DIALOG</span> oDlg <span style="color: #0000ff;">CENTERED</span> ;<br /> <span style="color: #0000ff;">ON</span> <span style="color: #0000ff;">PAINT</span> PaintPiano<span style="color: #000000;">(</span> hDC, oDlg <span style="color: #000000;">)</span> ;<br /> <span style="color: #0000ff;">ON</span> <span style="color: #0000ff;">CLICK</span> PlayPiano<span style="color: #000000;">(</span> nRow, nCol, oDlg <span style="color: #000000;">)</span><br /><br /> <span style="color: #0000ff;">RELEASE</span> <span style="color: #0000ff;">FONT</span> oFont<br /><br /><span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span><br /><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br /><span style="color: #00C800;">static</span> <span style="color: #00C800;">function</span> PaintPiano<span style="color: #000000;">(</span> hDC, oDlg <span style="color: #000000;">)</span><br /><br /> <span style="color: #00C800;">local</span> hBrush, hBrush2<br /> <span style="color: #00C800;">local</span> aKey<br /><br /> hBrush := CreateSolidBrush<span style="color: #000000;">(</span> CLR_WHITE <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">for</span> each aKey in aWhite<br /> <span style="color: #00C800;">if</span> aKey<span style="color: #000000;">[</span> <span style="color: #000000;">1</span> <span style="color: #000000;">]</span> == nKeyPress<br /> hBrush2 := CreateSolidBrush<span style="color: #000000;">(</span> RGB<span style="color: #000000;">(</span><span style="color: #000000;">255</span>,<span style="color: #000000;">255</span>,<span style="color: #000000;">150</span><span style="color: #000000;">)</span> <span style="color: #000000;">)</span><br /> FillRect<span style="color: #000000;">(</span> hDC, aKey<span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span>, hBrush2 <span style="color: #000000;">)</span><br /> DeleteObject<span style="color: #000000;">(</span> hBrush2 <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">else</span><br /> FillRect<span style="color: #000000;">(</span> hDC, aKey<span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span>, hBrush <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">endif</span><br /> PaintLabel<span style="color: #000000;">(</span> hDC, aKey<span style="color: #000000;">[</span> <span style="color: #000000;">4</span> <span style="color: #000000;">]</span>, aKey<span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span>, oDlg:<span style="color: #000000;">oFont</span>, CLR_BLACK <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">next</span><br /> DeleteObject<span style="color: #000000;">(</span> hBrush <span style="color: #000000;">)</span><br /><br /> hBrush := CreateSolidBrush<span style="color: #000000;">(</span> CLR_BLACK <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">for</span> each aKey in aBlack<br /> <span style="color: #00C800;">if</span> aKey<span style="color: #000000;">[</span> <span style="color: #000000;">1</span> <span style="color: #000000;">]</span> == nKeyPress<br /> hBrush2 := CreateSolidBrush<span style="color: #000000;">(</span> CLR_GRAY <span style="color: #000000;">)</span><br /> FillRect<span style="color: #000000;">(</span> hDC, aKey<span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span>, hBrush2 <span style="color: #000000;">)</span><br /> DeleteObject<span style="color: #000000;">(</span> hBrush2 <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">else</span><br /> FillRect<span style="color: #000000;">(</span> hDC, aKey<span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span>, hBrush <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">endif</span><br /> PaintLabel<span style="color: #000000;">(</span> hDC, aKey<span style="color: #000000;">[</span> <span style="color: #000000;">4</span> <span style="color: #000000;">]</span>, aKey<span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span>, oDlg:<span style="color: #000000;">oFont</span>, CLR_YELLOW <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">next</span><br /> DeleteObject<span style="color: #000000;">(</span> hBrush <span style="color: #000000;">)</span><br /><br /><span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span><br /><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br /><span style="color: #00C800;">static</span> <span style="color: #00C800;">function</span> PaintLabel<span style="color: #000000;">(</span> hDC, cLabel, aRect, oFont, nColor <span style="color: #000000;">)</span><br /><br /> <span style="color: #00C800;">local</span> nMode<br /><br /> <span style="color: #00C800;">if</span> Len<span style="color: #000000;">(</span> cLabel <span style="color: #000000;">)</span> == <span style="color: #000000;">1</span> <span style="color: #B900B9;">// White Key</span><br /> aRect := AClone<span style="color: #000000;">(</span> aRect <span style="color: #000000;">)</span><br /> aRect<span style="color: #000000;">[</span> <span style="color: #000000;">1</span> <span style="color: #000000;">]</span> += nHtBlack<br /> <span style="color: #00C800;">endif</span><br /><br /> nMode := SetBkMode<span style="color: #000000;">(</span> hDC, <span style="color: #000000;">1</span> <span style="color: #000000;">)</span><br /> SetTextColor<span style="color: #000000;">(</span> hDC, nColor <span style="color: #000000;">)</span><br /> oFont:<span style="color: #0000ff;">Activate</span><span style="color: #000000;">(</span> hDC <span style="color: #000000;">)</span><br /> DrawText<span style="color: #000000;">(</span> hDC, cLabel ,aRect , 0x25 <span style="color: #000000;">)</span> <span style="color: #B900B9;">// DT_SINGLELINE + DT_VCENTER + DT_CENTER</span><br /> oFont:<span style="color: #000000;">DeActivate</span><span style="color: #000000;">(</span> hDC <span style="color: #000000;">)</span><br /> SetBkMode<span style="color: #000000;">(</span> hDC, nMode <span style="color: #000000;">)</span><br /><br /><br /><br /><span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span><br /><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br /><span style="color: #00C800;">static</span> <span style="color: #00C800;">function</span> PlayPiano<span style="color: #000000;">(</span> nRow, nCol, oDlg <span style="color: #000000;">)</span><br /><br /> <span style="color: #00C800;">local</span> n, aKey<br /><br /> <span style="color: #00C800;">for</span> each aKey in <span style="color: #000000;">{</span> aBlack, aWhite <span style="color: #000000;">}</span><br /> <span style="color: #00C800;">if</span> nRow >= aKey<span style="color: #000000;">[</span> <span style="color: #000000;">1</span> <span style="color: #000000;">]</span><span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span><span style="color: #000000;">[</span> <span style="color: #000000;">1</span> <span style="color: #000000;">]</span> .and. nRow < aKey<span style="color: #000000;">[</span> <span style="color: #000000;">1</span> <span style="color: #000000;">]</span><span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span><span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span><br /> <span style="color: #00C800;">for</span> n := <span style="color: #000000;">1</span> <span style="color: #0000ff;">to</span> Len<span style="color: #000000;">(</span> aKey <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">if</span> nCol >= aKey<span style="color: #000000;">[</span> n <span style="color: #000000;">]</span><span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span><span style="color: #000000;">[</span> <span style="color: #000000;">2</span> <span style="color: #000000;">]</span><br /> <span style="color: #00C800;">if</span> nCol < aKey<span style="color: #000000;">[</span> n <span style="color: #000000;">]</span><span style="color: #000000;">[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">]</span><span style="color: #000000;">[</span> <span style="color: #000000;">4</span> <span style="color: #000000;">]</span><br /> nKeyPress := aKey<span style="color: #000000;">[</span> n <span style="color: #000000;">]</span><span style="color: #000000;">[</span> <span style="color: #000000;">1</span> <span style="color: #000000;">]</span><br /> oDlg:<span style="color: #0000ff;">Refresh</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /> SysRefresh<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br />#ifdef METHOD1<br /> TONE<span style="color: #000000;">(</span> aKey<span style="color: #000000;">[</span> n <span style="color: #000000;">]</span><span style="color: #000000;">[</span> <span style="color: #000000;">2</span> <span style="color: #000000;">]</span>, nDuration <span style="color: #000000;">)</span><br />#else<br /> TONE_2<span style="color: #000000;">(</span> aKey<span style="color: #000000;">[</span> n <span style="color: #000000;">]</span><span style="color: #000000;">[</span> <span style="color: #000000;">2</span> <span style="color: #000000;">]</span>, <span style="color: #ff0000;">"1/2"</span> <span style="color: #000000;">)</span><br />#endif<br /> nKeyPress := <span style="color: #000000;">0</span><br /> oDlg:<span style="color: #0000ff;">Refresh</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /> SysRefresh<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /> <span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span><br /> <span style="color: #00C800;">endif</span><br /> <span style="color: #00C800;">else</span><br /> EXIT<br /> <span style="color: #00C800;">endif</span><br /> <span style="color: #00C800;">next</span><br /> <span style="color: #00C800;">endif</span><br /> <span style="color: #00C800;">next</span><br /><br /><span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span><br /><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br /><span style="color: #00C800;">static</span> <span style="color: #00C800;">function</span> PrepareKeys<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> <span style="color: #00C800;">local</span> nGap := <span style="color: #000000;">4</span><br /> <span style="color: #00C800;">local</span> n, x, nTop, nLeft, nBottom<br /> <span style="color: #00C800;">local</span> nOctave<br /> <span style="color: #00C800;">local</span> aLabel := <span style="color: #000000;">{</span> <span style="color: #ff0000;">"C"</span>, <span style="color: #ff0000;">"C#"</span>, <span style="color: #ff0000;">"D"</span>, <span style="color: #ff0000;">"D#"</span>, <span style="color: #ff0000;">"E"</span>, <span style="color: #ff0000;">"F"</span>, <span style="color: #ff0000;">"F#"</span>, <span style="color: #ff0000;">"G"</span>, <span style="color: #ff0000;">"G#"</span>, <span style="color: #ff0000;">"A"</span>, <span style="color: #ff0000;">"A#"</span>, <span style="color: #ff0000;">"B"</span> <span style="color: #000000;">}</span><br /><br /> aWhite := <span style="color: #000000;">{</span><span style="color: #000000;">}</span><br /> nTop := aDlgMargin<span style="color: #000000;">[</span> <span style="color: #000000;">1</span> <span style="color: #000000;">]</span><br /> nLeft := aDlgMargin<span style="color: #000000;">[</span> <span style="color: #000000;">2</span> <span style="color: #000000;">]</span><br /> nBottom := nTop + nHtWhite<br /><br /> x := <span style="color: #000000;">0</span><br /> <span style="color: #00C800;">for</span> nOctave := <span style="color: #000000;">1</span> <span style="color: #0000ff;">to</span> nOctaves<br /> <span style="color: #00C800;">for</span> each n in <span style="color: #000000;">{</span> <span style="color: #000000;">1</span>, <span style="color: #000000;">3</span>, <span style="color: #000000;">5</span>, <span style="color: #000000;">6</span>, <span style="color: #000000;">8</span>, <span style="color: #000000;">10</span>, <span style="color: #000000;">12</span> <span style="color: #000000;">}</span><br /> AAdd<span style="color: #000000;">(</span> aWhite, <span style="color: #000000;">{</span> x + n, aTone<span style="color: #000000;">[</span> x + n <span style="color: #000000;">]</span>, <span style="color: #000000;">{</span> nTop, nLeft, nBottom, nLeft + nWdWhite <span style="color: #000000;">}</span>, aLabel<span style="color: #000000;">[</span> n <span style="color: #000000;">]</span> <span style="color: #000000;">}</span> <span style="color: #000000;">)</span><br /> nLeft += <span style="color: #000000;">(</span> nWdWhite + nGap <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">next</span><br /> x += <span style="color: #000000;">12</span><br /> <span style="color: #00C800;">next</span><br /><br /> aBlack := <span style="color: #000000;">{</span><span style="color: #000000;">}</span><br /> nLeft := aDlgMargin<span style="color: #000000;">[</span> <span style="color: #000000;">2</span> <span style="color: #000000;">]</span> + nWdWhite - Int<span style="color: #000000;">(</span> nWdBlack / <span style="color: #000000;">2</span> <span style="color: #000000;">)</span><br /> nBottom := nTop + nHtBlack<br /><br /> x := <span style="color: #000000;">0</span><br /> <span style="color: #00C800;">for</span> nOctave := <span style="color: #000000;">1</span> <span style="color: #0000ff;">to</span> nOctaves<br /> <span style="color: #00C800;">for</span> each n in <span style="color: #000000;">{</span> <span style="color: #000000;">2</span>, <span style="color: #000000;">4</span>, <span style="color: #000000;">7</span>, <span style="color: #000000;">9</span>, <span style="color: #000000;">11</span> <span style="color: #000000;">}</span><br /> AAdd<span style="color: #000000;">(</span> aBlack, <span style="color: #000000;">{</span> x + n, aTone<span style="color: #000000;">[</span> x + n <span style="color: #000000;">]</span>, <span style="color: #000000;">{</span> nTop, nLeft, nBottom, nLeft + nWdBlack <span style="color: #000000;">}</span>, aLabel<span style="color: #000000;">[</span> n <span style="color: #000000;">]</span> <span style="color: #000000;">}</span> <span style="color: #000000;">)</span><br /> nLeft += <span style="color: #000000;">(</span> nWdWhite + nGap <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">if</span> n == <span style="color: #000000;">4</span><br /> nLeft += <span style="color: #000000;">(</span> nWdWhite + nGap <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">endif</span><br /> <span style="color: #00C800;">next</span><br /> nLeft += <span style="color: #000000;">(</span> nWdWhite + nGap <span style="color: #000000;">)</span><br /> x += <span style="color: #000000;">12</span><br /> <span style="color: #00C800;">next</span><br /><br /><span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span><br /><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br /><span style="color: #00C800;">static</span> <span style="color: #00C800;">function</span> TONE_2<span style="color: #000000;">(</span> nFreq, cTempo <span style="color: #000000;">)</span> <span style="color: #B900B9;">// cTempo can be "1/2", "1/4", "1/8"</span><br /><br /> <span style="color: #00C800;">local</span> nTime<br /><br /> <span style="color: #00C800;">DEFAULT</span> cTempo := <span style="color: #ff0000;">"1/2"</span><br /><br /> nTime := &cTempo<br /> nTime *= <span style="color: #000000;">24</span><br /><br /><span style="color: #00C800;">return</span> TONE<span style="color: #000000;">(</span> nFreq, nTime <span style="color: #000000;">)</span><br /><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br /><span style="color: #00D7D7;">#pragma</span> BEGINDUMP<br /><br /><span style="color: #B900B9;">/*<br /> Author: Andi Jahja <harbour@cbn.net.id><br /><br /> TONE() for Windows to replace the ugly-heard GT Tone :-)<br /> Mono approach. Duration has been roughly estimated to be Cli**per-like,<br /> please refer to tests/sound.prg.<br /> Using Windows MMsystem, sound card is a must in order to make<br /> this function work.<br /><br /> Syntax: TONE( nFreq, nDuration, [ lSmooth ], [ nVol ] ) -> NIL<br /><br /> nFreq = INTEGER, Tone frequency<br /> nDuration = NUMERIC, Duration Time, as in Cl**per<br /> lSmooth = LOGICAL, pass .F. to disable sound smoothing, default is .T.<br /> nVol = INTEGER, Sound Intensity/Volume, value 0 - 127, Default 127 ( Max )<br /><br />*/</span><br /><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"hbapi.h"</span><br /><span style="color: #00D7D7;">#include</span> <windows.h><br /><span style="color: #00D7D7;">#include</span> <mmsystem.h><br /><span style="color: #00D7D7;">#include</span> <math.h><br /><br />#ifndef __XHARBOUR__<br /> <span style="color: #00D7D7;">#define</span> ISLOG<span style="color: #000000;">(</span> n <span style="color: #000000;">)</span> HB_ISLOG<span style="color: #000000;">(</span> n <span style="color: #000000;">)</span><br /> <span style="color: #00D7D7;">#define</span> ISNUM<span style="color: #000000;">(</span> n <span style="color: #000000;">)</span> HB_ISNUM<span style="color: #000000;">(</span> n <span style="color: #000000;">)</span><br />#endif<br /><br /><span style="color: #00D7D7;">#define</span> SAMPLING_RATE <span style="color: #000000;">44100</span><br /><br />void HB_EXPORT hb_winTone<span style="color: #000000;">(</span> UINT, double, BOOL, UINT <span style="color: #000000;">)</span>;<br /><br /><span style="color: #00C800;">HB_FUNC</span><span style="color: #000000;">(</span> TONE <span style="color: #000000;">)</span><br /><span style="color: #000000;">{</span><br /> <span style="color: #00C800;">if</span> ISNUM<span style="color: #000000;">(</span> <span style="color: #000000;">1</span> <span style="color: #000000;">)</span><br /> <span style="color: #000000;">{</span><br /> hb_winTone<span style="color: #000000;">(</span> hb_parni<span style="color: #000000;">(</span> <span style="color: #000000;">1</span> <span style="color: #000000;">)</span>,<br /> <span style="color: #000000;">(</span> ISNUM<span style="color: #000000;">(</span> <span style="color: #000000;">2</span> <span style="color: #000000;">)</span> ? hb_parnd<span style="color: #000000;">(</span> <span style="color: #000000;">2</span> <span style="color: #000000;">)</span> : <span style="color: #000000;">1.0</span> <span style="color: #000000;">)</span> * <span style="color: #000000;">2100</span>,<br /> ISLOG<span style="color: #000000;">(</span> <span style="color: #000000;">3</span><span style="color: #000000;">)</span> ? hb_parl<span style="color: #000000;">(</span> <span style="color: #000000;">3</span> <span style="color: #000000;">)</span> : <span style="color: #00C800;">TRUE</span>,<br /> ISNUM<span style="color: #000000;">(</span> <span style="color: #000000;">4</span> <span style="color: #000000;">)</span> ? hb_parni<span style="color: #000000;">(</span> <span style="color: #000000;">4</span> <span style="color: #000000;">)</span> : <span style="color: #000000;">127</span> <span style="color: #000000;">)</span>;<br /> <span style="color: #000000;">}</span><br /><span style="color: #000000;">}</span><br /><br /><span style="color: #B900B9;">/* Keep it here for access from C programs */</span><br />void HB_EXPORT hb_winTone<span style="color: #000000;">(</span> UINT uFrequency, double dwDuration, BOOL bSmoothing, UINT uVolume <span style="color: #000000;">)</span><br /><span style="color: #000000;">{</span><br /> WAVEFORMATEX wfx;<br /> HWAVEOUT hWaveOut = <span style="color: #00C800;">NULL</span>;<br /><br /> wfx.wFormatTag = WAVE_FORMAT_PCM;<br /> wfx.nChannels = <span style="color: #000000;">1</span>;<br /> wfx.nSamplesPerSec = SAMPLING_RATE;<br /> wfx.nAvgBytesPerSec = SAMPLING_RATE;<br /> wfx.nBlockAlign = <span style="color: #000000;">1</span>;<br /> wfx.wBitsPerSample = <span style="color: #000000;">8</span>;<br /> wfx.cbSize = <span style="color: #000000;">0</span>;<br /><br /> <span style="color: #B900B9;">/*<br /> WAVE_MAPPER is the most commonly used device<br /> CallBack is unnecessary since we only play simple tone<br /> */</span><br /> <span style="color: #00C800;">if</span><span style="color: #000000;">(</span> waveOutOpen<span style="color: #000000;">(</span> &hWaveOut, WAVE_MAPPER, &wfx, <span style="color: #00C800;">NULL</span>, <span style="color: #00C800;">NULL</span>, CALLBACK_NULL <span style="color: #000000;">)</span> == MMSYSERR_NOERROR <span style="color: #000000;">)</span><br /> <span style="color: #000000;">{</span><br /> char amp = uVolume;<br /> int i;<br /> unsigned char* buffer = <span style="color: #000000;">(</span>unsigned char*<span style="color: #000000;">)</span> hb_xgrab<span style="color: #000000;">(</span> <span style="color: #000000;">(</span>ULONG<span style="color: #000000;">)</span> dwDuration <span style="color: #000000;">)</span>;<br /> double dKoef = uFrequency * <span style="color: #000000;">2</span> * <span style="color: #000000;">3.14159</span> / SAMPLING_RATE;<br /> WAVEHDR wh;<br /><br /> <span style="color: #00C800;">if</span> <span style="color: #000000;">(</span> buffer <span style="color: #000000;">)</span><br /> <span style="color: #000000;">{</span><br /> wh.lpData = <span style="color: #000000;">(</span>LPSTR<span style="color: #000000;">)</span> buffer;<br /> wh.dwBufferLength = <span style="color: #000000;">(</span>DWORD<span style="color: #000000;">)</span> dwDuration;<br /> wh.dwFlags = WHDR_BEGINLOOP;<br /> wh.dwLoops = <span style="color: #000000;">1</span>;<br /><br /> <span style="color: #00C800;">if</span><span style="color: #000000;">(</span> waveOutPrepareHeader<span style="color: #000000;">(</span> hWaveOut, &wh, sizeof<span style="color: #000000;">(</span> wh <span style="color: #000000;">)</span> <span style="color: #000000;">)</span> == MMSYSERR_NOERROR <span style="color: #000000;">)</span><br /> <span style="color: #000000;">{</span><br /> wh.dwFlags = WHDR_BEGINLOOP | WHDR_ENDLOOP | WHDR_PREPARED;<br /> wh.dwLoops = <span style="color: #000000;">1</span>;<br /><br /> <span style="color: #00C800;">if</span> <span style="color: #000000;">(</span> bSmoothing <span style="color: #000000;">)</span><br /> <span style="color: #000000;">{</span><br /> <span style="color: #B900B9;">/*<br /> Manipulating data to smooth sound from clicks at the start<br /> and end (particularly noted when we call TONE() many times<br /> in a row). This is a simulation of increasing volume gradually<br /> before it reaches the peak, and decreasing volume gradually<br /> before it reaches the end.<br /> */</span><br /> <span style="color: #00C800;">for</span><span style="color: #000000;">(</span> i = <span style="color: #000000;">0</span>; i < dwDuration; i++ <span style="color: #000000;">)</span><br /> <span style="color: #000000;">{</span><br /> <span style="color: #00C800;">if</span> <span style="color: #000000;">(</span> i < amp <span style="color: #000000;">)</span><br /> <span style="color: #000000;">{</span><br /> buffer<span style="color: #000000;">[</span> i <span style="color: #000000;">]</span> = <span style="color: #000000;">(</span>unsigned char<span style="color: #000000;">)</span> <span style="color: #000000;">(</span> <span style="color: #0000ff;">cos</span><span style="color: #000000;">(</span> i * dKoef <span style="color: #000000;">)</span> * i + <span style="color: #000000;">127</span> <span style="color: #000000;">)</span>;<br /> <span style="color: #000000;">}</span><br /> <span style="color: #00C800;">else</span> <span style="color: #00C800;">if</span> <span style="color: #000000;">(</span> dwDuration - i <= amp - <span style="color: #000000;">1</span> <span style="color: #000000;">)</span><br /> <span style="color: #000000;">{</span><br /> amp = <span style="color: #0000ff;">max</span><span style="color: #000000;">(</span> <span style="color: #000000;">0</span>, --amp <span style="color: #000000;">)</span>;<br /> buffer<span style="color: #000000;">[</span> i <span style="color: #000000;">]</span> = <span style="color: #000000;">(</span>unsigned char<span style="color: #000000;">)</span> <span style="color: #000000;">(</span> <span style="color: #0000ff;">cos</span><span style="color: #000000;">(</span> i * dKoef <span style="color: #000000;">)</span> * amp + <span style="color: #000000;">127</span> <span style="color: #000000;">)</span>;<br /> <span style="color: #000000;">}</span><br /> <span style="color: #00C800;">else</span><br /> <span style="color: #000000;">{</span><br /> buffer<span style="color: #000000;">[</span> i <span style="color: #000000;">]</span> = <span style="color: #000000;">(</span>unsigned char<span style="color: #000000;">)</span> <span style="color: #000000;">(</span> <span style="color: #0000ff;">cos</span><span style="color: #000000;">(</span> i * dKoef <span style="color: #000000;">)</span> * amp + <span style="color: #000000;">127</span> <span style="color: #000000;">)</span>;<br /> <span style="color: #000000;">}</span><br /> <span style="color: #000000;">}</span><br /> <span style="color: #000000;">}</span><br /> <span style="color: #00C800;">else</span><br /> <span style="color: #000000;">{</span><br /> <span style="color: #B900B9;">/*<br /> Raw sound, may cause annoying clicks when some tones are played<br /> in a row.<br /> */</span><br /> <span style="color: #00C800;">for</span><span style="color: #000000;">(</span> i = <span style="color: #000000;">0</span>; i < <span style="color: #000000;">(</span>int<span style="color: #000000;">)</span> dwDuration; i++ <span style="color: #000000;">)</span><br /> <span style="color: #000000;">{</span><br /> buffer<span style="color: #000000;">[</span> i <span style="color: #000000;">]</span> = <span style="color: #000000;">(</span>unsigned char<span style="color: #000000;">)</span> <span style="color: #000000;">(</span> <span style="color: #0000ff;">cos</span><span style="color: #000000;">(</span> i * dKoef <span style="color: #000000;">)</span> * amp + <span style="color: #000000;">127</span> <span style="color: #000000;">)</span>;<br /> <span style="color: #000000;">}</span><br /> <span style="color: #000000;">}</span><br /><br /> <span style="color: #B900B9;">/*<br /> Play the sound here<br /> */</span><br /> <span style="color: #00C800;">if</span> <span style="color: #000000;">(</span> waveOutWrite<span style="color: #000000;">(</span> hWaveOut, &wh, sizeof<span style="color: #000000;">(</span>WAVEHDR<span style="color: #000000;">)</span> <span style="color: #000000;">)</span> == MMSYSERR_NOERROR <span style="color: #000000;">)</span><br /> <span style="color: #000000;">{</span><br /> <span style="color: #B900B9;">/*<br /> Wait until the sound is finished<br /> */</span><br /> <span style="color: #00C800;">while</span> <span style="color: #000000;">(</span>!<span style="color: #000000;">(</span>wh.dwFlags & WHDR_DONE<span style="color: #000000;">)</span><span style="color: #000000;">)</span><br /> <span style="color: #000000;">{</span><br /> <span style="color: #0000ff;">Sleep</span><span style="color: #000000;">(</span> <span style="color: #000000;">1</span> <span style="color: #000000;">)</span>;<br /> <span style="color: #000000;">}</span><br /><br /> waveOutUnprepareHeader<span style="color: #000000;">(</span>hWaveOut, &wh, sizeof<span style="color: #000000;">(</span>WAVEHDR<span style="color: #000000;">)</span><span style="color: #000000;">)</span>;<br /> <span style="color: #000000;">}</span><br /> <span style="color: #000000;">}</span><br /><br /> hb_xfree<span style="color: #000000;">(</span> buffer <span style="color: #000000;">)</span>;<br /> <span style="color: #000000;">}</span><br /> <span style="color: #000000;">}</span><br /><span style="color: #000000;">}</span><br /><br /><span style="color: #00D7D7;">#pragma</span> ENDDUMP<br /><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br /> </div>[/code:3itj5sj7] |
click a area of Tpanel control ( Creating a Piano) | Rao,
[img:1m4kxwcr]http://www.eoeo.it/wp-content/uploads/2014/12/Tabella-di-correlazione-tra-notazione-musicale-e-relative-frequenze-per-ottava.png[/img:1m4kxwcr]
We Initiated from 3 octave because a C with 130,8 is a good listen --- I'll like Know How make instrument path ( piano, guitar, drum)
Static aTone := { 130.8, 138.6, 146.8, 155.6, 164.8, 174.6, 185.0, 196.0, 207.7, 220.0, 233.1, 246.9,; // 3 octave
261.7, 277.2, 293.7, 311.1, 329.6, 349.2, 370.0, 392.0, 415.3, 440.0, 466.2, 493.9,; // 4 octave
523.3, 554.4, 587.3, 622.3, 659.3, 698.5, 740.0, 784.0, 830.6, 880.0, 932.3, 987.8,; // 5 octave
1047 , 1109, 1175, 1245, 1319, 1397, 1480, 1568, 1661, 1760, 1865, 1976 ,; // 6 octave
2093 , 2217, 2349, 2489, 2637, 2794, 2960, 3136, 3322, 3520, 3729, 3951 } // 7 octave
I arrive on 4 octave ( 48 keys) .. I insert your modifies and the post the new sources
I add also the possibility to save the music on a file and load music from this file |
click a area of Tpanel control ( Creating a Piano) | After finalizing the frequencies for all octaves, please share the final values with me.
How can we make the duration controlled by the user? That is the tone should start playing when the user presses the key and stop when he releases the key.( ofcourse that is not piano). I like to have this variation also. |
click a area of Tpanel control ( Creating a Piano) | Mr. Rao,
on tone function of Andy try to wrote
#define SAMPLING_RATE 126100
instead of
#define SAMPLING_RATE 44100
it change the duration of note
Perhaps we can found a function to control it !!!
See it please I add :
now the Piano have [b:23fkesmw]60[/b:23fkesmw] keys !!!!! ( use with METHOD1 active)
[b:23fkesmw]Border and Background[/b:23fkesmw]
[b:23fkesmw]Save music on ini file [/b:23fkesmw]
[b:23fkesmw]Load music from inifile [/b:23fkesmw] ( it play the music but the keys not are light)
[b:23fkesmw]From menu you can create a new song file or load one saved!!!!![/b:23fkesmw] |
click a area of Tpanel control ( Creating a Piano) | a Demo song to try with new sources
Save with :[b:230slutu] Birthday.ini [/b:230slutu]
[code=fw:230slutu]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><span style="color: #000000;">[</span>Music<span style="color: #000000;">]</span><br />Note=<span style="color: #000000;">42</span><br /><span style="color: #000000;">1</span>=G2T1/<span style="color: #000000;">4</span><br /><span style="color: #000000;">2</span>=G2T1/<span style="color: #000000;">8</span><br /><span style="color: #000000;">3</span>=A2T1/<span style="color: #000000;">4</span><br /><span style="color: #000000;">4</span>=PT1/<span style="color: #000000;">8</span><br /><span style="color: #000000;">5</span>=G2T1/<span style="color: #000000;">4</span><br /><span style="color: #000000;">6</span>=PT1/<span style="color: #000000;">8</span><br /><span style="color: #000000;">7</span>=C3T1/<span style="color: #000000;">4</span><br /><span style="color: #000000;">8</span>=PT1/<span style="color: #000000;">8</span><br /><span style="color: #000000;">9</span>=H2T1/<span style="color: #000000;">4</span><br /><span style="color: #000000;">10</span>=PT1/<span style="color: #000000;">2</span><br /><span style="color: #000000;">11</span>=G2T1/<span style="color: #000000;">4</span><br /><span style="color: #000000;">12</span>=G2T1/<span style="color: #000000;">8</span><br /><span style="color: #000000;">13</span>=A2T1/<span style="color: #000000;">4</span><br /><span style="color: #000000;">14</span>=PT1/<span style="color: #000000;">8</span><br /><span style="color: #000000;">15</span>=G2T1/<span style="color: #000000;">4</span><br /><span style="color: #000000;">16</span>=PT1/<span style="color: #000000;">8</span><br /><span style="color: #000000;">17</span>=D3T1/<span style="color: #000000;">4</span><br /><span style="color: #000000;">18</span>=PT1/<span style="color: #000000;">8</span><br /><span style="color: #000000;">19</span>=C3T1/<span style="color: #000000;">4</span><br /><span style="color: #000000;">20</span>=PT1/<span style="color: #000000;">2</span><br /><span style="color: #000000;">21</span>=G2T1/<span style="color: #000000;">4</span><br /><span style="color: #000000;">22</span>=G2T1/<span style="color: #000000;">8</span><br /><span style="color: #000000;">23</span>=G3T1/<span style="color: #000000;">4</span> <br /><span style="color: #000000;">24</span>=PT1/<span style="color: #000000;">8</span><br /><span style="color: #000000;">25</span>=E3T1/<span style="color: #000000;">4</span> <br /><span style="color: #000000;">26</span>=PT1/<span style="color: #000000;">8</span><br /><span style="color: #000000;">27</span>=C3T1/<span style="color: #000000;">4</span> <br /><span style="color: #000000;">28</span>=C3T1/<span style="color: #000000;">8</span> <br /><span style="color: #000000;">29</span>=H2T1/<span style="color: #000000;">4</span><br /><span style="color: #000000;">30</span>=PT1/<span style="color: #000000;">8</span><br /><span style="color: #000000;">31</span>=A2T1/<span style="color: #000000;">4</span><br /><span style="color: #000000;">32</span>=PT1/<span style="color: #000000;">8</span><br /><span style="color: #000000;">33</span>=F3T1/<span style="color: #000000;">4</span> <br /><span style="color: #000000;">34</span>=F3T1/<span style="color: #000000;">8</span> <br /><span style="color: #000000;">35</span>=E3T1/<span style="color: #000000;">4</span> <br /><span style="color: #000000;">36</span>=PT1/<span style="color: #000000;">8</span><br /><span style="color: #000000;">37</span>=C3T1/<span style="color: #000000;">4</span> <br /><span style="color: #000000;">38</span>=PT1/<span style="color: #000000;">8</span><br /><span style="color: #000000;">39</span>=D3T1/<span style="color: #000000;">4</span> <br /><span style="color: #000000;">40</span>=PT1/<span style="color: #000000;">8</span><br /><span style="color: #000000;">41</span>=C3T1/<span style="color: #000000;">4</span> <br /><span style="color: #000000;">42</span>=PT1/<span style="color: #000000;">2</span><br /> </div>[/code:230slutu] |
click derecho en area de notificación | Hola a todos,
me gustaría saber si alguien conoce la manera de hacer click derecho sobre un icono en el área de notificación.
Me explico: tengo un programa que se comparte entre varias personas a través de una cuenta de google drive, cuando el programa arranca se descargan los ficheros y el programa espera a que todos los ficheros que se necesitan se descarguen correctamente, esto lo hace drive solito. Al acabar me gustaría que antes des salir se mostrara el proceso de sincronizacion de cambios de los archivos haciendo click derecho sobre el icono de drive en el área de notificación, pero no sé cómo hacer esto.
Saludos, |
click derecho en area de notificación | Do you mean this?
[code=fw:2c7qarnv]<div class="fw" id="{CB}" style="font-family: monospace;"> <span style="color: #00C800;">METHOD</span> <span style="color: #00C800;">New</span><span style="color: #000000;">(</span> oWnd, oIcon, cTip, uLClick, uRClick, uMMoved, uLDblClick, uLButtonUp,;<br /> uRButtonUp <span style="color: #000000;">)</span> CONSTRUCTOR</div>[/code:2c7qarnv]
Please look at the fifth parameter (uRClick).
EMG |
click derecho en area de notificación | No, I mean right-click on the Google Drive icon and show the pop-ip window.
Regards,
[img:2yv0t1m6]http://alanit.com/wp-content/uploads/2022/05/Captura-de-pantalla-2022-05-31-195308.png[/img:2yv0t1m6] |
click derecho en area de notificación | Sorry, I don't understand.
EMG |
click derecho en area de notificación | Estimado Jose Luis,
Aqui tienes detallado el proceso para hacerlo:
[url:30p3zv3u]https://stackoverflow.com/questions/21335917/simulating-right-click-on-system-tray-icon-and-clicking-on-context-menu-in-c[/url:30p3zv3u] |
click sobre tree con checkbox | Hola a Todos:
Tengo un Treeview , quiero que haga algo al marcar el check y que se grabe o sea al almar de nuevo el tree debe estar marcado o marcados los que ya clickiee. Tengo el evento al darle click sobre la rama mas no sobre el checkbox. ¿Alguien ya ha resuelto esto?
desde ya muchas gracias.
atte Miguel Salas
México |
click sobre tree con checkbox | Miguel,
Con ayuda del buen amigo William Morales, hace tiempo hice lo que necesitas, armar un tree y al seleccionar algunas opciones, estas se graben y despues cuando lo vuelvas a mostrar, salgan ya activas.
Sin embargo, quiero comentarte algo : Cuando son muchas las opciones del tree y mandas un Expand, tarda unos 5-7 segundos para que salgan los datos. Hace poco actualize el xHarbour y me empezo a encimar los nombres de las opciones quedando totalmente ilegible, Por lo que opte por implementar el tree en un xBrowse y los resultados fueron muy satisfactorios : mucho mas rapido y sin problemas de pintado.
Deja busco un respaldo del codigo por si te interesa.
Saludos |
click sobre tree con checkbox | te agradezco la respuesta y en espera de tu valiosa ayuda
saludos |
click sobre tree con checkbox | Miguel,
[color=#FF0000:2fkngpe3]En alguna tabla o dbf debes tener uno o varios campos para guardar las claves de los items seleccionados, yo los separo usando ':'[/color:2fkngpe3]
[code=fw:2fkngpe3]<div class="fw" id="{CB}" style="font-family: monospace;">oTree := TTreeView<span style="color: #000000;">(</span><span style="color: #000000;">)</span>:<span style="color: #0000ff;">ReDefine</span><span style="color: #000000;">(</span> <span style="color: #000000;">101</span>, oCatUsrFldr:<span style="color: #000000;">aDialogs</span><span style="color: #000000;">[</span><span style="color: #000000;">2</span><span style="color: #000000;">]</span>, CLR_BLACK, CLR_WHITE, .f. ,<span style="color: #ff0000;">"RSTree"</span> <span style="color: #000000;">)</span><br />oTree:<span style="color: #000000;">oFont</span> := aSysFnts<span style="color: #000000;">[</span><span style="color: #000000;">9</span><span style="color: #000000;">]</span></div>[/code:2fkngpe3]
// Elementos del tree[code=fw:2fkngpe3]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><span style="color: #000000;">{</span><span style="color: #ff0000;">'1101021'</span> ,<span style="color: #ff0000;">' Notas De Mostrador'</span> ,<span style="color: #ff0000;">'K003'</span><span style="color: #000000;">}</span>, ;<br /><span style="color: #000000;">{</span><span style="color: #ff0000;">'1101022'</span> ,<span style="color: #ff0000;">' Facturas'</span> ,<span style="color: #ff0000;">'K004'</span><span style="color: #000000;">}</span>, ;<br /><span style="color: #000000;">{</span><span style="color: #ff0000;">'1101023'</span> ,<span style="color: #ff0000;">' Cotizaciones'</span> ,<span style="color: #ff0000;">'K005'</span><span style="color: #000000;">}</span>, ;<br /><span style="color: #000000;">{</span><span style="color: #ff0000;">'1101024'</span> ,<span style="color: #ff0000;">' Ventas Express'</span> ,<span style="color: #ff0000;">'K006'</span><span style="color: #000000;">}</span>, ;<br /><span style="color: #000000;">{</span><span style="color: #ff0000;">'1101025'</span> ,<span style="color: #ff0000;">' Preventas/Pedidos'</span> ,<span style="color: #ff0000;">'K007'</span><span style="color: #000000;">}</span>, ;</div>[/code:2fkngpe3]
// Obtener items seleccionados[code=fw:2fkngpe3]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><span style="color: #00C800;">static</span> <span style="color: #00C800;">function</span> GetUOptsSld<span style="color: #000000;">(</span> oTree, aItems <span style="color: #000000;">)</span><br /><span style="color: #00C800;">local</span> n, nCargo<br /><br /><span style="color: #00C800;">for</span> n = <span style="color: #000000;">1</span> <span style="color: #0000ff;">to</span> len<span style="color: #000000;">(</span> aItems <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">if</span> oTree:<span style="color: #000000;">GetCheck</span><span style="color: #000000;">(</span> aItems<span style="color: #000000;">[</span>n<span style="color: #000000;">]</span> <span style="color: #000000;">)</span><br /> nCargo := aItems<span style="color: #000000;">[</span> n <span style="color: #000000;">]</span>:<span style="color: #000000;">cargo</span><br /> <span style="color: #00C800;">if</span> ascan<span style="color: #000000;">(</span> aUsrOptsSld, <span style="color: #000000;">{</span>|n| n == nCargo<span style="color: #000000;">}</span> <span style="color: #000000;">)</span> == <span style="color: #000000;">0</span><br /> aadd<span style="color: #000000;">(</span> aUsrOptsSld, aItems<span style="color: #000000;">[</span>n<span style="color: #000000;">]</span>:<span style="color: #000000;">cargo</span> <span style="color: #000000;">)</span> <span style="color: #B900B9;">// Aqui guardo la clave de los items seleccionados : K003, K004, etc</span><br /> <span style="color: #00C800;">endif</span><br /> <span style="color: #00C800;">endif</span><br /> GetUOptsSld<span style="color: #000000;">(</span> oTree, aItems<span style="color: #000000;">[</span>n<span style="color: #000000;">]</span>:<span style="color: #000000;">aItems</span> <span style="color: #000000;">)</span><br /><span style="color: #00C800;">next</span><br /> <br /><span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span><br />*-----*</div>[/code:2fkngpe3]
// Actualizar items seleccionados[code=fw:2fkngpe3]<div class="fw" id="{CB}" style="font-family: monospace;"><br />aOpts2Apl := HB_ATokens<span style="color: #000000;">(</span> aDmXDts<span style="color: #000000;">[</span><span style="color: #000000;">1</span>,<span style="color: #000000;">1</span><span style="color: #000000;">]</span>, <span style="color: #ff0000;">":"</span>, .f., .f. <span style="color: #000000;">)</span><br /><br />SrcOptsValues<span style="color: #000000;">(</span> oTree, aItems, aOpts2Apl <span style="color: #000000;">)</span><br />oTree:<span style="color: #0000ff;">Refresh</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /><span style="color: #00C800;">static</span> <span style="color: #00C800;">function</span> SrcOptsValues<span style="color: #000000;">(</span> oTree, aItems, aOptsGrntd <span style="color: #000000;">)</span><br /><span style="color: #00C800;">local</span> nQ<br /><br /><span style="color: #00C800;">for</span> nQ := <span style="color: #000000;">1</span> <span style="color: #0000ff;">to</span> len<span style="color: #000000;">(</span> aItems <span style="color: #000000;">)</span><br /> oTree:<span style="color: #000000;">SetCheck</span><span style="color: #000000;">(</span> aItems<span style="color: #000000;">[</span>nQ<span style="color: #000000;">]</span>, .f. <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">if</span> ascan<span style="color: #000000;">(</span> aOptsGrntd, aItems<span style="color: #000000;">[</span>nQ<span style="color: #000000;">]</span>:<span style="color: #000000;">cargo</span> <span style="color: #000000;">)</span> > <span style="color: #000000;">0</span><br /> oTree:<span style="color: #000000;">SetCheck</span><span style="color: #000000;">(</span> aItems<span style="color: #000000;">[</span>nQ<span style="color: #000000;">]</span>, .t. <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">endif</span><br /> SrcOptsValues<span style="color: #000000;">(</span> oTree, aItems<span style="color: #000000;">[</span>nQ<span style="color: #000000;">]</span>:<span style="color: #000000;">aItems</span>, aOptsGrntd <span style="color: #000000;">)</span><br /><span style="color: #00C800;">next</span><br /><br /><span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span><br />*-----*</div>[/code:2fkngpe3]
Cualquier dudad estamos a la orden.
Saludos |
click sobre tree con checkbox | Te agradezco infinitamente Raymundo... dejame probarlo y te comento |
click sobre tree con checkbox | unas dudas,:
1- No veo en el codigo que uses la funcion "GetUOptsSld" (solo dentro de si misma ¿?)
2- El array aDmXDts ¿con que lo llenas?
3.- SrcOptsValues() la llamas al llenar el Tree?
como ves ando perdido en esto
saludos |
click sobre tree con checkbox | Miguel,
1- No veo en el codigo que uses la funcion "GetUOptsSld" (solo dentro de si misma ¿?)
[code=fw:2g2evi2x]<div class="fw" id="{CB}" style="font-family: monospace;">Cuando termino de seleccionar las opciones deseadas, mando llamar esta funcion para que recorra el tree y mando a un a un arreglo el cargo del elemento, que en este caso es la clave de la opcion. Y son las que se van a grabar en un campo.</div>[/code:2g2evi2x]
2- El array aDmXDts ¿con que lo llenas?
[code=fw:2g2evi2x]<div class="fw" id="{CB}" style="font-family: monospace;">En mi caso, lo lleno desde un query del campo donde grabe las opciones previamente seleccionadas y grabadas, asi que, primero armas tu tree con tus opciones y enseguida le indicas cuales fueron seleccionadas previamente para que se muestren con tal atributo.</div>[/code:2g2evi2x]
3.- SrcOptsValues() la llamas al llenar el Tree?
[code=fw:2g2evi2x]<div class="fw" id="{CB}" style="font-family: monospace;">Igual al punto anterior, se arma el tree, y despues le aplicas las opciones seleccionadas previamente.</div>[/code:2g2evi2x]
Y sip, en efecto, las funciones SrcOptsValues() y GetUOptsSld() se llaman recursivamente para recorrer todos los branches del tree.
ya tienes la rutina para armar tu tree ? ya que ahi es donde esta el asunto para armar los "niveles" de tu tree.
Saludos |
click sobre tree con checkbox | Amigo Raymundo, tiene un ejemplo mas didactico con array
Saludos |
clickable image | Hello,
I have a window with 4 tabs. On tab 3 I want to show 1 to 10 images (depending on how much images I have) and when I click on that image I want to show it in a new window on real size. I have looked in the examples, but not all of them are working correctly. The example testsimage gives errors while compiling.
For now I use the ON WINDOW CLICK command, but when tab 4 is active I get to see the result of tab 3. Is there a function that I can check which tab is active/shown, or is there a way to make the image clickable.
Also I want to determine the size of the image to show in the new window, so I can make the window as big as the image. How can I find the sizes of the image?
[code=fw:zukxn7oj]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #0000ff;">DEFINE</span> <span style="color: #0000ff;">DIALOG</span> oDlg <span style="color: #0000ff;">TITLE</span> <span style="color: #ff0000;">"Detailscherm"</span> + STR<span style="color: #000000;">(</span>nPlantnum<span style="color: #000000;">)</span> ;<br /> <span style="color: #0000ff;">FROM</span> <span style="color: #000000;">0</span>, <span style="color: #000000;">0</span> <span style="color: #0000ff;">TO</span> <span style="color: #000000;">500</span>, <span style="color: #000000;">720</span><br /><br /> @ <span style="color: #000000;">450</span>, <span style="color: #000000;">10</span> <span style="color: #0000ff;">GET</span> oGetNaam <span style="color: #0000ff;">VAR</span> cLatijnNaam <span style="color: #0000ff;">OF</span> oDlg <span style="color: #0000ff;">SIZE</span> <span style="color: #000000;">700</span>, <span style="color: #000000;">40</span><br /> <br /> oGetNaam:<span style="color: #000000;">SetFont</span><span style="color: #000000;">(</span> <span style="color: #ff0000;">"Geneva"</span>, <span style="color: #000000;">24</span> <span style="color: #000000;">)</span><br /> oGetNaam:<span style="color: #000000;">SetColor</span><span style="color: #000000;">(</span> OwnClrGreen, OwnClrYellow <span style="color: #000000;">)</span><br /> <br /> @ <span style="color: #000000;">40</span>, <span style="color: #000000;">10</span> <span style="color: #0000ff;">FOLDER</span> oFld <span style="color: #0000ff;">SIZE</span> <span style="color: #000000;">700</span>, <span style="color: #000000;">400</span> <span style="color: #0000ff;">OF</span> oDlg ;<br /> PAGES <span style="color: #ff0000;">"Gegevens"</span>, <span style="color: #ff0000;">"Kenmerken"</span>, <span style="color: #ff0000;">"Fotos"</span>, <span style="color: #ff0000;">"Combinaties"</span> ;<br /> <br />*first tabblad, gegevens<br /> @ <span style="color: #000000;">0</span>, <span style="color: #000000;">0</span> BROWSE oBrw1 FIELDS <span style="color: #ff0000;">""</span>, <span style="color: #ff0000;">""</span> ;<br /> HEADERS <span style="color: #ff0000;">""</span>, <span style="color: #ff0000;">""</span> ;<br /> <span style="color: #0000ff;">OF</span> oFld:<span style="color: #000000;">aControls</span><span style="color: #000000;">[</span> <span style="color: #000000;">1</span> <span style="color: #000000;">]</span> <span style="color: #0000ff;">SIZE</span> <span style="color: #000000;">680</span>, <span style="color: #000000;">350</span><br /><br /> oBrw1:<span style="color: #000000;">SetArray</span><span style="color: #000000;">(</span> aGegevens <span style="color: #000000;">)</span><br /> oBrw1:<span style="color: #000000;">bLine</span> = <span style="color: #000000;">{</span> | nRow | <span style="color: #00C800;">IF</span><span style="color: #000000;">(</span> nRow <= Len<span style="color: #000000;">(</span> aGegevens <span style="color: #000000;">)</span>, aGegevens<span style="color: #000000;">[</span> nRow <span style="color: #000000;">]</span>, <span style="color: #000000;">{</span> <span style="color: #ff0000;">""</span>, <span style="color: #ff0000;">""</span> <span style="color: #000000;">}</span> <span style="color: #000000;">)</span> <span style="color: #000000;">}</span><br /> oBrw1:<span style="color: #000000;">SetColWidth</span><span style="color: #000000;">(</span> <span style="color: #000000;">1</span>, <span style="color: #000000;">150</span> <span style="color: #000000;">)</span><br /> oBrw1:<span style="color: #000000;">SetColWidth</span><span style="color: #000000;">(</span> <span style="color: #000000;">2</span>, <span style="color: #000000;">500</span> <span style="color: #000000;">)</span><br /> oBrw1:<span style="color: #000000;">SetColor</span><span style="color: #000000;">(</span> OwnClrGreen, OwnClrYellow <span style="color: #000000;">)</span><br /> oBrw1:<span style="color: #000000;">SetFocus</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /> <br />*second tabblad, kenmerken<br /> @ <span style="color: #000000;">0</span>, <span style="color: #000000;">0</span> BROWSE oBrw2 FIELDS <span style="color: #ff0000;">""</span>, <span style="color: #ff0000;">""</span> ;<br /> HEADERS <span style="color: #ff0000;">""</span>, <span style="color: #ff0000;">""</span> ;<br /> <span style="color: #0000ff;">OF</span> oFld:<span style="color: #000000;">aControls</span><span style="color: #000000;">[</span> <span style="color: #000000;">2</span> <span style="color: #000000;">]</span> <span style="color: #0000ff;">SIZE</span> <span style="color: #000000;">680</span>, <span style="color: #000000;">350</span><br /><br /> oBrw2:<span style="color: #000000;">SetArray</span><span style="color: #000000;">(</span> aKenmerken <span style="color: #000000;">)</span><br /> oBrw2:<span style="color: #000000;">bLine</span> = <span style="color: #000000;">{</span> | nRow | <span style="color: #00C800;">If</span><span style="color: #000000;">(</span> nRow <= Len<span style="color: #000000;">(</span> aKenmerken <span style="color: #000000;">)</span>, aKenmerken<span style="color: #000000;">[</span> nRow <span style="color: #000000;">]</span>, <span style="color: #000000;">{</span> <span style="color: #ff0000;">""</span>, <span style="color: #ff0000;">""</span> <span style="color: #000000;">}</span> <span style="color: #000000;">)</span> <span style="color: #000000;">}</span><br /> oBrw2:<span style="color: #000000;">SetColWidth</span><span style="color: #000000;">(</span> <span style="color: #000000;">1</span>, <span style="color: #000000;">150</span> <span style="color: #000000;">)</span><br /> oBrw2:<span style="color: #000000;">SetColWidth</span><span style="color: #000000;">(</span> <span style="color: #000000;">2</span>, <span style="color: #000000;">500</span> <span style="color: #000000;">)</span><br /> oBrw2:<span style="color: #000000;">SetColor</span><span style="color: #000000;">(</span> OwnClrGreen, OwnClrYellow <span style="color: #000000;">)</span><br /> oBrw2:<span style="color: #000000;">SetFocus</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br />*third tabblad, foto<span style="color: #ff0000;">'s<br /> FOR r = 1 TO 3<br /> FOR k = 1 TO 5<br /> cImage := aFotoNaam[nFoto]<br /> IF FILE(cImage)<br /> @ nRow, nColumn IMAGE oImg FILENAME cImage OF oFld:aControls[ 3 ] SIZE 110, 110<br /> ENDIF<br /> nColumn := nColumn + 120<br /> nFoto++<br /> NEXT<br /> nColumn := 10<br /> nRow := nRow - 120<br /> NEXT<br /><br />*fourth tabblad, combinaties<br /><br /> @ 10, 10 BUTTON "OK" OF oDlg ACTION oDlg:End()<br /> <br /> <br /> <br />ACTIVATE DIALOG oDlg CENTERED;<br />ON CLICK RK_FotoGroot( nRow , nCol )[<br /><br />FUNCTION RK_FotoGroot(nRow, nCol)<br />*to show a big picture<br /><br />LOCAL nFoto := 1<br />LOCAL oWndFoto<br />LOCAL oFoto<br /><br />MsgInfo(STR(nTab))<br /><br />IF nRow < 400 .AND. nRow > 290<br /> IF nCol > 30 .AND. nCol < 140<br /> nFoto := 1<br /> ELSEIF nCol > 150 .AND. nCol < 260<br /> nFoto := 2<br /> ELSEIF nCol > 270 .AND. nCol < 380<br /> nFoto := 3<br /> ELSEIF nCol > 390 .AND. nCol < 500<br /> nFoto := 4<br /> ELSEIF nCol > 510 .AND. nCol < 620<br /> nFoto := 5<br /> ENDIF<br />ELSEIF nRow < 280 .AND. nrow > 170<br /> IF nCol > 30 .AND. nCol < 140<br /> nFoto := 6<br /> ELSEIF nCol > 150 .AND. nCol < 260<br /> nFoto := 7<br /> ELSEIF nCol > 270 .AND. nCol < 380<br /> nFoto := 8<br /> ELSEIF nCol > 390 .AND. nCol < 500<br /> nFoto := 9<br /> ELSEIF nCol > 510 .AND. nCol < 620<br /> nFoto := 10<br /> ENDIF<br />ELSEIF nRow < 160 .AND. nRow > 50<br /> IF nCol > 30 .AND. nCol < 140<br /> nFoto := 11<br /> ELSEIF nCol > 150 .AND. nCol < 260<br /> nFoto := 12<br /> ELSEIF nCol > 270 .AND. nCol < 380<br /> nFoto := 13<br /> ELSEIF nCol > 390 .AND. nCol < 500<br /> nFoto := 14<br /> ELSEIF nCol > 510 .AND. nCol < 620<br /> nFoto := 15<br /> ENDIF<br />ENDIF<br /><br />IF FILE(aFotoNaam[nFoto])<br /><br /> DEFINE DIALOG oWndFoto TITLE "grote foto" ;<br /> FROM 0, 0 TO 800, 1000<br /> <br /> @ 10, 10 IMAGE oFoto FILENAME aFotoNaam[nFoto] OF oWndFoto SIZE 710, 950<br /> <br /> ACTIVATE DIALOG oWndFoto<br /> <br />ENDIF<br /><br />RETURN NIL</span></div>[/code:zukxn7oj] |
clickable image | Rene,
> Is there a function that I can check which tab is active/shown
oTabs:nTab
> is there a way to make the image clickable
oImage:bLButtonUp = { | nRow, nCol | ImageClick() }
> How can I find the sizes of the image?
oImage:nWidth and oImage:nHeight |
clickable image | Rene,
This is not working yet:
oImage:bLButtonUp = { | nRow, nCol | ImageClick() }
I am implementing it |
clickable image | Rene,
Already implemented. Here you have a working example:
[code=fw:1a3dfg3u]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"FiveMac.ch"</span><br /><br /><span style="color: #00C800;">function</span> Main<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> <span style="color: #00C800;">local</span> oWnd, oImg<br /><br /> <span style="color: #0000ff;">DEFINE</span> <span style="color: #0000ff;">WINDOW</span> oWnd ;<br /> <span style="color: #0000ff;">FROM</span> <span style="color: #000000;">444</span>, <span style="color: #000000;">89</span> <span style="color: #0000ff;">TO</span> <span style="color: #000000;">689</span>, <span style="color: #000000;">500</span><br /> <br /> oWnd:<span style="color: #0000ff;">center</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /> <br /> @ <span style="color: #000000;">100</span>, <span style="color: #000000;">139</span> <span style="color: #0000ff;">IMAGE</span> oImg <span style="color: #0000ff;">OF</span> oWnd <span style="color: #0000ff;">SIZE</span> <span style="color: #000000;">107</span>, <span style="color: #000000;">91</span> FILENAME ImgPath<span style="color: #000000;">(</span><span style="color: #000000;">)</span> + <span style="color: #ff0000;">"fivetech.gif"</span><br /><br /> oImg:<span style="color: #000000;">bLButtonDown</span> = <span style="color: #000000;">{</span> || <span style="color: #0000ff;">MsgInfo</span><span style="color: #000000;">(</span> oImg:<span style="color: #000000;">nWidth</span> <span style="color: #000000;">)</span> <span style="color: #000000;">}</span><br /><br /> @ <span style="color: #000000;">69</span>, <span style="color: #000000;">95</span> <span style="color: #0000ff;">SAY</span> <span style="color: #ff0000;">"(c) FiveTech Software 2007-2012"</span> <span style="color: #0000ff;">OF</span> oWnd <span style="color: #0000ff;">SIZE</span> <span style="color: #000000;">210</span>, <span style="color: #000000;">14</span><br /> <br /> @ <span style="color: #000000;">22</span>, <span style="color: #000000;">150</span> <span style="color: #0000ff;">BUTTON</span> <span style="color: #ff0000;">"Ok"</span> <span style="color: #0000ff;">OF</span> oWnd <span style="color: #0000ff;">ACTION</span> oWnd:<span style="color: #000000;">End</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /> <br /> @ <span style="color: #000000;">22</span>, <span style="color: #000000;">250</span> <span style="color: #0000ff;">BUTTON</span> <span style="color: #ff0000;">"Frame"</span> <span style="color: #0000ff;">OF</span> oWnd <span style="color: #0000ff;">ACTION</span> <span style="color: #000000;">(</span> <span style="color: #0000ff;">MsgInfo</span><span style="color: #000000;">(</span> oImg:<span style="color: #000000;">nWidth</span> <span style="color: #000000;">)</span>, oImg:<span style="color: #000000;">setFrame</span><span style="color: #000000;">(</span> <span style="color: #000000;">)</span> <span style="color: #000000;">)</span><br /> <br /> <span style="color: #0000ff;">ACTIVATE</span> <span style="color: #0000ff;">WINDOW</span> oWnd<br /> <br /><span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span></div>[/code:1a3dfg3u]
You can use bLButtonDown or LButtonUp, as you prefer.
I have emailed you the new FiveMac libs already. Many thanks for your feedback |
clickable image | Hello Antonio,
Thanks for the reply and new libs. The oImg:bLButtonDown and the oTabs:nTab works perfect. Only the oImg:nWidth gives the width (and height) of the control, not the width of the real picture.
I want to know the real sizes of the image. When i make an image size 110, 110 and place a picture of 640x480 px on it, the image is shown cropped on the image control. When I click on that control I want to make a window of nWidht+20 and nHeight+60 to show the picture. |
clickable image | This seems to be the right way to get the image dimensions:
[code=fw:fcjkeuvp]<div class="fw" id="{CB}" style="font-family: monospace;">NSImageRep *rep = <span style="color: #000000;">[</span><span style="color: #000000;">[</span><span style="color: #0000ff;">image</span> representations<span style="color: #000000;">]</span> objectAtIndex:<span style="color: #000000;">0</span><span style="color: #000000;">]</span>;<br />NSSize imageSize = NSMakeSize<span style="color: #000000;">(</span>rep.pixelsWide, rep.pixelsHigh<span style="color: #000000;">)</span>;</div>[/code:fcjkeuvp]
[url:fcjkeuvp]http://stackoverflow.com/questions/11876963/get-the-correct-image-width-and-height-of-an-nsimage[/url:fcjkeuvp]
I am going to test it |
clickable image | Rene,
Already implemented and working fine. I have sent you the modifed libs already.
Simply do:
MsgInfo( oImage:GetWidth() )
and
MsgInfo( oImage:GetHeight() )
many thanks for your feedback |
clickable image | Hello Antonio,
The nWidth and nHeight gives the sizes of the defined object, not of the picture.
I have a picture of 480 px height and 640 px width. When I place this on my BigPhoto window the sizes given are the sizes I have dementioned. See code:
[code=fw:10n5nz75]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #00C800;">FUNCTION</span> RK_BigPhoto<span style="color: #000000;">(</span>cImage<span style="color: #000000;">)</span><br />*<span style="color: #0000ff;">to</span> show a big <span style="color: #0000ff;">picture</span><br />*the cImage is 480x640 px<br /><span style="color: #00C800;">LOCAL</span> oWndFoto<br /><span style="color: #00C800;">LOCAL</span> oFoto<br /><br /> <span style="color: #0000ff;">DEFINE</span> <span style="color: #0000ff;">DIALOG</span> oWndFoto <span style="color: #0000ff;">TITLE</span> <span style="color: #ff0000;">"big picture"</span> ;<br /> <span style="color: #0000ff;">FROM</span> <span style="color: #000000;">0</span>, <span style="color: #000000;">0</span> <span style="color: #0000ff;">TO</span> <span style="color: #000000;">800</span>, <span style="color: #000000;">1000</span><br /> <br /> @ <span style="color: #000000;">30</span>, <span style="color: #000000;">10</span> <span style="color: #0000ff;">IMAGE</span> oFoto FILENAME cImage <span style="color: #0000ff;">OF</span> oWndFoto <span style="color: #0000ff;">SIZE</span> <span style="color: #000000;">710</span>, <span style="color: #000000;">950</span><br /> oFoto:<span style="color: #000000;">bLButtonDown</span> = <span style="color: #000000;">{</span> || <span style="color: #0000ff;">MsgInfo</span><span style="color: #000000;">(</span> oFoto:<span style="color: #000000;">nWidth</span> <span style="color: #000000;">)</span> <span style="color: #000000;">}</span><br /><br /> @ <span style="color: #000000;">10</span>, <span style="color: #000000;">250</span> <span style="color: #0000ff;">BUTTON</span> <span style="color: #ff0000;">"Frame"</span> <span style="color: #0000ff;">OF</span> oWndFoto <span style="color: #0000ff;">ACTION</span> <span style="color: #000000;">(</span> <span style="color: #0000ff;">MsgInfo</span><span style="color: #000000;">(</span> oFoto:<span style="color: #000000;">nHeight</span> <span style="color: #000000;">)</span>, oFoto:<span style="color: #000000;">setFrame</span><span style="color: #000000;">(</span> <span style="color: #000000;">)</span> <span style="color: #000000;">)</span><br /> <br /> <span style="color: #0000ff;">ACTIVATE</span> <span style="color: #0000ff;">DIALOG</span> oWndFoto<br /><br /><span style="color: #00C800;">RETURN</span> <span style="color: #00C800;">NIL</span><br /> </div>[/code:10n5nz75]
Now when I click on the oFoto the width 710 is given( picture is 640 px, when I click on the button the height 950 is given picture is 480px
Can I do this another way? |
clickable image | Rene,
You have to use oFoto:GetWidth() and oFoto:GetHeight() |
clickable image | Hello Antonio,
Sorry, yes that was the trick. I was forgotten to put the newest lib in the lib-folder. thats why I got an error. I have to work more exact. Tomorrow I will put my newest code on Git, so you can see the progress. |
clickable image | Rene,
ok, thanks, I will pull and test it |
clickable image | Hello Antonio,
I have put the latest version on git
I have put some comments in the source, so its easier to understand
Rene |
clickable image | Rene,
I already reviewed it and I sent you an email |
client RDP info | hi all,
I need to know a unique value of the remote client from the server rdp.
is possible?
Thank you for your reponse. |
client RDP info | Hello,
What I do is to take the user name with which the user entered.
[code=fw:1p9fohq8]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #00C800;">Function</span> ListUsersTs<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><span style="color: #00C800;">local</span> oLoc := CreateObject<span style="color: #000000;">(</span> <span style="color: #ff0000;">"wbemScripting.SwbemLocator"</span> <span style="color: #000000;">)</span><br /><span style="color: #00C800;">local</span> oSrv := oLoc:<span style="color: #000000;">ConnectServer</span><span style="color: #000000;">(</span>,<span style="color: #ff0000;">"root<span style="color: #000000;">\c</span>imv2"</span><span style="color: #000000;">)</span><br /><span style="color: #00C800;">local</span> aDat := oSrv:<span style="color: #000000;">ExecQuery</span><span style="color: #000000;">(</span> <span style="color: #ff0000;">"SELECT * FROM Win32_UserAccount"</span> <span style="color: #000000;">)</span><br /><span style="color: #00C800;">Local</span> oDat<br /><span style="color: #00C800;">Local</span> aRet := <span style="color: #000000;">{</span><span style="color: #ff0000;">""</span><span style="color: #000000;">}</span><br /><br /> <span style="color: #00C800;">For</span> each oDat in aDat<br /> AADD<span style="color: #000000;">(</span>aRet, AllTrim<span style="color: #000000;">(</span> Upper<span style="color: #000000;">(</span> oDat:<span style="color: #0000ff;">Name</span> <span style="color: #000000;">)</span> <span style="color: #000000;">)</span> <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">Next</span><br /><br /><span style="color: #00C800;">Return</span><span style="color: #000000;">(</span> aRet <span style="color: #000000;">)</span></div>[/code:1p9fohq8] |
client_multi_queries | I want to set option after my TMySqlServer(.....) connection is set to enable execution of multiple queries separated by ';' each.
Please help. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.