Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
OnScreenDisplay text, centered relative to the window
#1
hello,

I need OnScreenDisplay text, relative to the current window, centered display, not centered relative to the screen, is this possible?
The following code is that the left alignment of the relative window, center alignment, is somewhat difficult  Smile

Thanks in advance!
david


Macro Macro10
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 324 136 "Dialog" "4"
;3 Button 0x54032000 0x0 140 64 48 14 "Display Text"
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C02 "*" "" "" ""

if(!ShowDialog(dd &sub.DlgProc 0)) ret


#sub DlgProc
function# hDlg message wParam lParam
int x y w
GetWinXY hDlg x y w
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 3 ;;Button
,OnScreenDisplay "Hello World" 0.8 x y "" 36 0xC000C0 1
ret 1
#2
This code is not perfect, but simple. To center perfectly would need some programming.

Code:
Copy      Help
,case 3 ;;Button
,RECT r; GetWindowRect hDlg &r
,OnScreenDisplay "Hello World" 0.8 (r.left+r.right)/2-100 (r.top+r.bottom)/2-20 "" 36 0xC000C0 1|16 "osdCenter18649"
#3
In QM3 it's easy.

C# code:
// script ""

var b = new wpfBuilder("Window").WinSize(400, 400);
b.R.AddButton("Button", _ => _Osd("Hello C#"));
b.R.AddOkCancel();
b.End();
#if WPF_PREVIEW //menu Edit -> View -> WPF preview
b.Window.Preview();
#endif
if (!b.ShowDialog()) return;
//print.it(text1.Text, combo1.SelectedIndex, c1.IsChecked == true);


void _Osd(string text) {
    osdText.showText(text, 1, PopupXY.In(b.Window.Hwnd().Rect));
}
#4
Thanks for your help,

Use the following code when the text length needs to be displayed dynamically changing , Centering fails

Macro Macro10
Code:
Copy      Help
,case 3 ;;Button
,RECT r; GetWindowRect hDlg &r
,OnScreenDisplay "Hello World" 0.8 (r.left+r.right)/2-100 (r.top+r.bottom)/2-20 "" 36 0xC000C0 1|16 "osdCenter18649"
#5
In Quick Macros not so easy to center automatically when text is changing.
In the new program easier; I can create an example if need.
#6
I tried other methods without success, 
I would like to learn about the programming methods in QM2, thanks again  Heart
#7
Now when the new C# program is available, probably not worth to learn QM2 programming. It is OK to use QM2 for simple scripts, but I see you like programming level scripts. Then C# is million times better. Both programs can be used simultaneously. I won't help creating programming-level QM code that requires much time to create, but I'll be happy to help with C# scripts.
#8
It was a great idea, thanks again


Forum Jump:


Users browsing this thread: 1 Guest(s)