Página 1 de 1

GTwvw - É possível trocar coord. de LIN/COL por PÍXELS?

Enviado: 30 Ago 2012 01:05
por Dr.Microso
Prezados, saudações!

GTwvw
Há possibilidade de trocar coordenadas de LINHA x COLUNA ou seja SetMode(), por PÍXEL (altura/largura), na definição de telas, imagens, e outros "objetos"?
Como faria por exemplo, para criar uma janela de 640x480 e posicionar uma imagem de 300x200 em certa posição?

As outras GTs permitem isso ou são similares à WVW em funcionamento?
Em tempo: quais tipos de imagens a WVW suporta?

Um abraço!

GTwvw - É possível trocar coord. de LIN/COL por PÍXELS?

Enviado: 01 Set 2012 15:46
por Imatech
Olá Dr.Microso !
.
.
.
Desconheço essa possiblidade e nos fontes tambem não temos referencia a essa possiblidade...
.
.
.
Sucesso...

GTwvw - É possível trocar coord. de LIN/COL por PÍXELS?

Enviado: 06 Set 2012 13:55
por Dr.Microso
Caro Imatech, grato pelo feedback!

Nunca tinha me aventurado pela WVW que, apesar de tida como obsoleta, me parece a forma mais rápida e indolor para uma migração rápida... Achei bem documentada! Para quem quer contornar as limitações impostas pelo Windows aos app de 16 bits, conferindo um aspecto GUI que pode ser aprimorado, não vi nada melhor. Recomendo!

Um abraço!

GTwvw - É possível trocar coord. de LIN/COL por PÍXELS?

Enviado: 06 Set 2012 15:39
por Imatech
Olá !
.
.
.
Obrigado pela dica...
.
.
.
Recomendo tambem, como solução definitiva estudar hbQT ou hwGui
.
.
.
Sucesso...

GTwvw - É possível trocar coord. de LIN/COL por PÍXELS?

Enviado: 18 Set 2012 14:32
por bencz
Olá, já tive esse mesmo problema, e a solução que eu utilizei foi essa veja:

Código: Selecionar todos

HDC hDC;
TEXTMETRIC textMetric;
HFONT   hFont, hOldFont;
int sizeInPpoints, lineHeight;
RECT textRect;
char *buffer = "Comprimento em pixels desta string!";
 
hDC = GetDC(hwnd);
sizeInPpoints = MulDiv(10, GetDeviceCaps(hDC, LOGPIXELSY), 72);
hFont = CreateFont(-sizeInPpoints, 0, 0, 0, FW_NORMAL, 0, 0, 0, 0, 0, 0, 0, 0, "Courier New");
hOldFont = (HFONT)SelectObject(hDC, hFont);
 
GetTextMetrics(hDC, &textMetric);
 
lineHeight = textMetric.tmHeight; // character height in current font

textRect.left = textRect.right = textRect.top = textRect.bottom = 0;
DrawText(hDC, buffer, strlen(buffer), &textRect, DT_CALCRECT);
 
printf("Tamanho do texto calculado pelo DrawText: [%d x %d]\n", textRect.right, textRect.bottom);
printf("Altura do texto calculado pelo GetTextMetrics: %d\n", lineHeight);
Bom, não é exatamente, com exatidão o mesmo problema ( pleonasmo 0 aqui nesta frase xD ), mas, vc pode tentar utilizar a mesma solução (:
vc passa por parametros oque você precisa calcular, e pronto (:

GTwvw - É possível trocar coord. de LIN/COL por PÍXELS?

Enviado: 18 Set 2012 15:06
por Pablo César
Colega Bencz, podia dar um exemplo ? E como adaptar no Harbour ?

GTwvw - É possível trocar coord. de LIN/COL por PÍXELS?

Enviado: 20 Set 2012 18:54
por bencz
Claro, com todo o prazer (:

Código: Selecionar todos

function main
   ? GETPIXELSIZE("Ola mundo")
   wait
return nil

#pragma BEGINDUMP

#include <Windows.h>
#include "hbapi.h"

#define BUFSIZE 1024

HWND GetConsoleHwnd(void)
{
   HWND hwndFound;
   char pszNewWindowTitle[BUFSIZE];
   char pszOldWindowTitle[BUFSIZE];
   GetConsoleTitle(pszOldWindowTitle, BUFSIZE);
   hwndFound=FindWindow(NULL, pszNewWindowTitle);
   SetConsoleTitle(pszOldWindowTitle);
   return(hwndFound);
}

HB_FUNC ( GETPIXELSIZE )
{
   HDC hDC;
   TEXTMETRIC textMetric;
   HFONT   hFont, hOldFont;
   int sizeInPpoints, lineHeight;
   RECT textRect;
   HWND hwnd = GetConsoleHwnd();
   const char *buffer = hb_parc(1);
   const char *fontType = "Courier New";

   hDC = GetDC(hwnd);
   sizeInPpoints = MulDiv(10, GetDeviceCaps(hDC, LOGPIXELSY), 90);
   hFont = CreateFont(-sizeInPpoints, 0, 0, 0, FW_NORMAL, 0, 0, 0, 0, 0, 0, 0, 0, fontType);
   hOldFont = (HFONT)SelectObject(hDC, hFont);

   GetTextMetrics(hDC, &textMetric);

   lineHeight = textMetric.tmHeight;

   textRect.left = textRect.right = textRect.top = textRect.bottom = 0;
   DrawText(hDC, buffer, strlen(buffer), &textRect, DT_CALCRECT);

   hb_retnl(textRect.right);
}

#pragma ENDDUMP
Neste caso, ele vai retornar o comprimento da string { Ola mundo } em pixels... (:

GTwvw - É possível trocar coord. de LIN/COL por PÍXELS?

Enviado: 13 Out 2012 20:02
por Claudio Soto
Hola a todos, aquí les dejo una función general para obtener el largo y el ancho de un texto para un determinado tipo y tamaño de fuente.
Ejemplo:

aSize := BT_TEXT_SIZE (hWnd, "Hola Mundo", "Times New Roman", 14, BT_TEXT_BOLD + BT_TEXT_ITALIC)
nSizeTextWIDTH := aSize [1]
nSizeTextHEIGHT := aSize [2]

Saludos,
Claudio Soto.

Código: Selecionar todos

#pragma BEGINDUMP

#define WINVER 0x0500  // minimum requirements: Windows 2000
#include <windows.h>
#include "hbapi.h"

// (c) Dr. Claudio Soto
// srvet@adinet.com.uy
// http://srvet.blogspot.com 
// Setiembre 2012, Uruguay

//*******************************************************************************************************************
//* BT_TEXT_SIZE (hWnd, cText, cFontName, nFontSize, nType) ---> Return Array = { nSizeTextWIDTH, nSizeTextHEIGHT }
//*******************************************************************************************************************

// Type
#define BT_TEXT_BOLD        2
#define BT_TEXT_ITALIC      4
#define BT_TEXT_UNDERLINE   8
#define BT_TEXT_STRIKEOUT   16

HB_FUNC (BT_TEXT_SIZE)
{
   HDC  hDC;
   HFONT hFont;
   SIZE SizeText;
   HWND hWnd;
   CHAR *Text, *FontName;
   INT FontSize;
   INT Type;
   
   INT Bold = FW_NORMAL;
   INT Italic = 0, Underline = 0, StrikeOut = 0;

   hWnd        = (HWND)     hb_parnl  (1);
   Text        = (CHAR *)   hb_parcx  (2);
   FontName    = (CHAR *)   hb_parcx  (3);
   FontSize    = (INT)      hb_parni  (4);  // Size of font in logic points
   Type        = (INT)      hb_parni  (5);
      
   hDC = GetDC (hWnd);
      
   if ((Type & BT_TEXT_BOLD) == BT_TEXT_BOLD)
       Bold = FW_BOLD;
   
   if ((Type & BT_TEXT_ITALIC) == BT_TEXT_ITALIC)    
       Italic = 1;
   
   if ((Type & BT_TEXT_UNDERLINE) == BT_TEXT_UNDERLINE)       
       Underline = 1;
       
   if ((Type & BT_TEXT_STRIKEOUT) == BT_TEXT_STRIKEOUT)    
       StrikeOut = 1;
   
   FontSize = FontSize * GetDeviceCaps (hDC, LOGPIXELSY) / 72;   

   hFont = CreateFont (0-FontSize, 0, 0, 0, Bold, Italic, Underline, StrikeOut,
           DEFAULT_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, FontName);
   
   SelectObject (hDC, hFont);
    
   GetTextExtentPoint32 (hDC, Text, lstrlen(Text), &SizeText);
   hb_reta (2);
   hb_storvnl ((LONG) SizeText.cx, -1, 1); 
   hb_storvnl ((LONG) SizeText.cy, -1, 2); 

   DeleteObject (hFont);
   ReleaseDC (hWnd, hDC);   
}

#pragma ENDDUMP