Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Maximizing and Resizing Dialog
#3
Here you have a full example, I had this lying around.
It contains a simple multiline inputfield which resizes with the dialog.
Compile this to .exe to make the systray icon appear. (you have to first check a setting in the compile to exe dialog, read below green comment)
When you minimized the dialog you can left click on the systray icon to make it re appear.

Read the green comments for further instructions/info.

This can probably be done much better/cleaner it is meant as a starting point for you.
Create a new smart dialog and copy and paste all the below code over the existing code then compile to exe and run it.
(you do not have to run the .exe you can run the code itself, it just has to be compiled to exe once this is to make the icon appear)


Function autosize_test_dlg
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90CF0AC8 0x0 0 0 224 136 "Dialog"
;3 Edit 0x54231044 0x200 0 0 225 138 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040601 "*" "" "" ""

str controls = "3"
str e3
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,,int- dlg_id
,,dlg_id=hDlg ;; Put the id of th dialog in this variable
,,;;........................................................
,,;;. The below code is for resizing the multiline inputfield
,,;;[1]...............................................
,,
,,;; 1. Go to dialog editor and click on the dialog, the red dot needs to be on the dialog! (NOT a on a control within in the dialog)
,,;; 2. In dialog editor, above from the left click on the third icon next to the i- icon (it has a small red check mark at top left)
,,;; 3. In the next dialog that appears (that has all the dialog styles) click on 'WS_THICKFRAME' (if you want minimize/maximize, also click on 'WS_MINIMIZEBOX' and 'WS_MAXIMIZEBOX')
,,;; 4. Below line, press [F1] on  light blue function, 3s ==> '3'=control ID  's'=resize
,,
,,DT_SetAutoSizeControls hDlg "3s"
,,
,,;;........................................................
,,;;. The below code is for showing a systray icon and a simple menu when click on the systray icon.
,,;;. You can ignore (delete) it, if you do not need it.
,,;;[2]...............................................
,,
,,
,,
,,;; 1. replace 'shell32.dll,9' in 'str icons=' with path to .ico, example: 'x:\path\to\some_icon.ico'
,,;; 2. compile this application to .exe
,,;;    In the compile to exe dialog, check the checkbox: "Auto add file used in macro if resource id specified...."
,,;; - When you run this dialog with 'shell32.dll,9' specified as icon, you will see a default icon (probably network icon) as the systray icon
,,;; - you can right click the systray and 2 menu items appear 'test 1' and 'test 2' when you select of them it will output 'test 1' or 'test 2'
,,;; - [CONTROL]+right clicking the systray icon closes/exists this dialog
,,;; - A left click on the systray icon activates this dialog (minimize the dialog then press the systray icon)
,,str icons=
,,;:97 shell32.dll,9
,,;
,,Tray- t.AddIcon(":97" "dialog title" 0 &sub.TrayCallback) ;; You can change "dialog title", this will be displayed when you hover over the systray icon
,,
,,;; Or in stead of 'sub.TrayCallback' you can use an external function, below I used 'autosize_test_dlg_SystrayClick'
,,;; create function 'autosize_test_dlg_SystrayClick' and put code of above 'sub.TrayCallback' in it
,,;; Tray- t.AddIcon(":97" "dialog title" 0 &autosize_test_dlg_SystrayClick)
,,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1



#sub TrayCallback
function Tray&x message

;Callback function for Tray.AddIcon.
;Called for each received message - when tray icon clicked, or mouse moved.
;
;x - reference to this object.
;message - mouse message (WM_MOUSEMOVE, WM_LBUTTONDOWN, etc).


;OutWinMsg message 0 0 ;;uncomment to see received messages
int- dlg_id ;; This is the id of the dialog
sel message
,case WM_LBUTTONUP
,,act dlg_id

,case WM_RBUTTONUP
,,sel GetMod
,,,case 0 ;; NORMAL RIGHT CLICK ON SYSTRAY ICON
,,,,sub.OnTrayIconRightClick x.param
,,,case 2 ;; [CTRL]+ SYSTRAY CLICK CLOSES THIS APPLICATION
,,,,shutdown -7



,case WM_MBUTTONUP
,;out "middle click"


;;........................................................
;;. GETMOD
;;[JIDM955]...............................................
;
;#GetMod ;;Returns: 1 Shift, 2 Ctrl, 4 Alt, 8 Win.
;Checks whether modifier keys are pressed. The return value is combination of the following values: 1 - Shift is pressed, 2 - Ctrl is pressed, 4 - Alt is pressed, 8 Win is pressed. For example, if Ctrl and Alt are pressed, the return value is 6.
;;;
;Example
;if(GetMod&2) out "Ctrl pressed"
;;;
;---------------------------------
;
;FormatKeyString !vk !mod str&s ;;mod:   1 Shift, 2 Ctrl, 4 Alt, 8 Win.
;Gets key name for a key and/or modifiers. The text will be like "Ctrl+Page Up".
;;;;
;vk - virtual-key code.
;mod - modifiers. See GetMod.
;s - variable that receives the text. If the variable initially is not empty, appends to the end.


#sub OnTrayIconRightClick

function param

;created and can be edited with the Menu Editor
int- dlg_id
str md=
;BEGIN MENU
;Test 1 :601
;Test 2 :602
;END MENU

int i=ShowMenu(md)
if(i=601)out "Test 1"
if(i=602)out "Test 2"


Messages In This Thread
RE: Maximizing and Resizing Dialog - by Kevin - 02-15-2019, 06:23 PM
RE: Maximizing and Resizing Dialog - by r0n - 02-15-2019, 08:13 PM
RE: Maximizing and Resizing Dialog - by Kevin - 02-16-2019, 01:37 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)