NO

Author Topic: Dialog Units to pixels rounding problems  (Read 4976 times)

czerny

  • Guest
Dialog Units to pixels rounding problems
« on: May 08, 2013, 10:16:55 AM »
I have the following problem: I have some controls in a vertical distance of 12 dialog units. But this rounds to a pixel distance plus/minus 1 pixel (see picture). Because of the very small distance it looks not very nice.
I do not like to write extra code to adjust the positions afterwards.

Is there a little trick to avoid this phenomenon? I use tahoma. Is there a font with a better DLU/Pixel ratio?

« Last Edit: May 08, 2013, 11:43:39 AM by czerny »

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Dialog Units to pixels rounding problems
« Reply #1 on: May 08, 2013, 05:46:26 PM »
I can't understand what the problem is ?
Can you explain what problem is with this tiny example ?
Code: [Select]
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

LRESULT CALLBACK MainDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
return TRUE;
case WM_CLOSE:
EndDialog(hwndDlg, 0);
return TRUE;
}
return FALSE;
}

int __cdecl WinMainCRTStartup(void)
{
return DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(1001), NULL, (DLGPROC)MainDlgProc);
}
Code: [Select]
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

1001 DIALOGEX DISCARDABLE 6, 18, 82, 38
STYLE DS_SHELLFONT|WS_POPUP|DS_MODALFRAME|DS_3DLOOK|WS_CAPTION|WS_SYSMENU|WS_VISIBLE
CAPTION "Dialog"
FONT 8, "Tahoma", 0, 0, 1
{
  CONTROL "This label:", 4001, "Static", WS_GROUP, 0, 0, 40, 12, WS_EX_CLIENTEDGE
  CONTROL "Edit", 4002, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 40, 0, 40, 12
  CONTROL "This label:", 4003, "Static", WS_GROUP, 0, 12, 40, 12, WS_EX_CLIENTEDGE
  CONTROL "Edit", 4004, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 40, 12, 40, 12
  CONTROL "This label:", 4005, "Static", WS_GROUP, 0, 24, 40, 12, WS_EX_CLIENTEDGE
  CONTROL "Edit", 4006, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 40, 24, 40, 12
}
May the source be with you

czerny

  • Guest
Re: Dialog Units to pixels rounding problems
« Reply #2 on: May 08, 2013, 10:52:55 PM »
Just set the controls 1 unit lower. The horizontal border lines differ 1 pixel.
Code: [Select]
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

1001 DIALOGEX DISCARDABLE 6, 18, 82, 38
STYLE DS_SHELLFONT|WS_POPUP|DS_MODALFRAME|DS_3DLOOK|WS_CAPTION|WS_SYSMENU|WS_VISIBLE
CAPTION "Dialog"
FONT 8, "Tahoma", 0, 0, 1
{
  CONTROL "This label:", 4001, "Static", WS_GROUP, 0, 1, 40, 12, WS_EX_CLIENTEDGE
  CONTROL "Edit", 4002, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 40, 1, 40, 12
  CONTROL "This label:", 4003, "Static", WS_GROUP, 0, 13, 40, 12, WS_EX_CLIENTEDGE
  CONTROL "Edit", 4004, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 40, 13, 40, 12
  CONTROL "This label:", 4005, "Static", WS_GROUP, 0, 25, 40, 12, WS_EX_CLIENTEDGE
  CONTROL "Edit", 4006, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 40, 25, 40, 12
}

Offline jj2007

  • Member
  • *
  • Posts: 536
Re: Dialog Units to pixels rounding problems
« Reply #3 on: November 17, 2014, 01:37:52 PM »
The bot brigade is back: "Zandra" copied randomly one of my old posts.
The Masm32 forum also got two similar posts today, just crap, seems to be a problem with the Simple Machines forum software.

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Dialog Units to pixels rounding problems
« Reply #4 on: November 17, 2014, 02:23:07 PM »
Ok
let's start cleaning for now ...  >:(
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide