Jump to content

Recommended Posts

Posted (edited)

Okay two quick questions:

Numero Uno:

I was trying to duplicate a function of the Run dialog. Try this out. Hit browse, browse to a file, and then select it. The location of this file will be put into the top of the combo box. But, if you drop down the box, it's not within that list. The only two ways I can see to add an item to the list like this are:

(a) GuiCtrlSetData($ctrlId, '|' & $newItem & '|' & $allOldItems)

(B) ControlSetText($gui, '', $ctrlId, $newItem)

But two problems with that. (a) adds the item to the drop down list, the method used by the Run dialog does not. Whereas (B) doesn't seem to realize that the text has been changed. This is just a minor gripe, barely even a gripe at all, but I was wondering if there was a way to do what I ask (currently I'm using method (a) and I actually prefer it to the actual Run dialog's method).

I guess you could say this first question was more curious in nature. :)

Oh and on a somewhat related note, it seems none of the ControlCommand commands work with Combo boxes.

Anyway.. Question Number Two:

Wondering if there's any chance of incorporating this control:

Posted Image

AutoIt window spy calls it "SysMonthCal321"

If it helps, I found the source to the program featuring it (called TClock2). I'm assuming that the "deskcal.c" file within the source .zip is related to the calendar control... but I can't make heads or tails of it.

CODE
void DialogCalender(HWND hwnd)

{

HWND hwndTray;

INITCOMMONCONTROLSEX icc;

hwndTray = FindWindow("Shell_TrayWnd", NULL);

if(g_hDlgCalender && IsWindow(g_hDlgCalender))

;

else

{

icc.dwSize = sizeof(INITCOMMONCONTROLSEX);

icc.dwICC = ICC_DATE_CLASSES;

InitCommonControlsEx(&icc);

g_hDlgCalender = CreateDialog(GetLangModule(), MAKEINTRESOURCE(121),

hwnd, (DLGPROC)DlgProcCalender);

}

SetForegroundWindow98(g_hDlgCalender);

}

Edited by Saunders
Posted (edited)

Well I think that it's called 'SysMonthCal32' but never mind - it's posible to include this calerdar control in a browser control with the CWebPage.dll library BUT not to get any result returned - the dhtml code looks like this...

Use the string function like in this example...

#include <GUIConstants.au3>

$dll = DLLOpen("cwebpage.dll") ; load in the Html library

$a = '<OBJECT classid="clsid:232E456A-87C3-11D1-8BE3-0000F8754DA1" ID=MonthView>'

$a = $a & '<param name=BackColor value="16787215">'

$a = $a & '<param name=Appearance value=0>'

$a = $a & '<param name=Enabled value=1>'

$a = $a & '<param name=MonthColumns value=1>'

$a = $a & '<param name=MonthRows value=1>'

$a = $a & '<param name=MonthBackColor value=-2147483643>'

$a = $a & '<param name=ShowToday value=1>'

$a = $a & '<param name=ShowWeekNumbers value=0>'

$a = $a & '<param name=StartOfWeek value=662831106>'

$a = $a & '<param name=TitleBackColor value=-2147483633>'

$a = $a & '<param name=TitleForeColor value=-2147483630>'

$a = $a & '<param name=CurrentDate value=37642>'

$a = $a & '</OBJECT>'

$Main = GUICreate("Calendar control",800,400,1,1)

GUISetState()

DLLCall($dll,"long","EmbedBrowserObject","hwnd",$main) ; attach the browser object from library

DLLCall($dll,"long","DisplayHTMLStr","hwnd",$Main,"str",$a); display the html code in the browser control

While 1

$msg = GUIGetMsg()

If @error Then Exitloop

If $msg = -3 Then ExitLoop

WEnd

Exit

Func OnAutoItExit()

DLLCall($dll,"long","UnEmbedBrowserObject","hwnd",$main)

DLLClose($dll)

EndFunc

You can use the a child window to control the location of the calendar control BUT you can't get returns from this only change the control parametre...

Kåre :)

Edited by kjactive
Posted (edited)

Anyway.. Question Number Two:

Wondering if there's any chance of incorporating this control:

Cople days ago it's was rather impossible, but with great Ejoc's Dll/UDF now it's already real, though also a bit clunky:

#include <GUIConstants.au3>
#include "DllMem.au3"

$hGUI = GUICreate("")
Global $GWL_HINSTANCE = -6
$hInstance = DLLCall( "user32.dll", "long", "GetWindowLong", "hwnd", $hGUI, "int", $GWL_HINSTANCE)
$hInstance = $hInstance[0]

; Now Dll not supported "word" size, so double structure
$struct = "byte;byte;byte;byte;byte;byte;byte;byte;byte;byte;byte;byte;byte;byte;byte;byte"

$DTM = _DllMemCreate($struct)

$MCM_FIRST = 0x1000;
$MCM_GETCURSEL = ($MCM_FIRST + 1);

$ret = DllCall("user32.dll", "hwnd", "CreateWindowEx", _
        "long", 0, _
        "str", "SysMonthCal32", _
        "str", "", _
        "long", BitOr($WS_CHILD, $WS_VISIBLE), _
        "int", 5, _
        "int", 5, _
        "int", 200, _ 
        "int", 200, _
        "hwnd", $hGUI, _
        "hwnd", 0, _
        "int", $hInstance, _
        "ptr", "")

$hDM = $ret[0]

GUISetState()

While 1
    $nMsg = GUIGetMsg()
    If $nMsg = $GUI_EVENT_CLOSE then 

        $ret = DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $hDM, "int", $MCM_GETCURSEL, "int", 0, "ptr", $DTM)
        $s = ""
        $k = ""
        For $i = 0 To 3
            For $j = 1 to 0 step -1
                $k = $k & Hex(_DllMemGet($DTM, $struct, $i*2 + $j), 2)
            Next
            $s = $s & Dec($k) & "/"
            $k = ""
        Next
        MsgBox (0, "Date selected:", StringTrimRight($s,1))
    Exit
    Endif
Wend

I'm very hope that struct ability will be incorporated into DllCall.

Edited by Lazycat
Posted (edited)

Ahh, there we go. See, at this point I wasn't even looking for interactability, I just wanted to throw the control itself onto a GUI. Your code showed me the DllCall needed. Thanks LazyCat.

(And upon trying your code with the DllMem stuff, it doesn't seemed to have worked anyway, always returns 0/0/0/0).

Now knowing the DllCall parameters I've created this:

CODE
#include <GUIConstants.au3>

Global Const $GWL_HINSTANCE = -6

$gui_Main = GuiCreate('Calendar', 176, 154, -1, -1, -1, BitOr($WS_EX_CLIENTEDGE, $WS_EX_TOOLWINDOW))

$h_Instance = DllCall('user32.dll', 'long', 'GetWindowLong', _

'hwnd', $gui_Main, _

'int', $GWL_HINSTANCE)

$h_Instance = $h_Instance[0]

$ret = DllCall('user32.dll', 'hwnd', 'CreateWindowEx', _

'long', 0, _

'str', 'SysMonthCal32', _

'str', '', _

'long', BitOr($WS_CHILD, $WS_VISIBLE), _

'int', 0, _

'int', 0, _

'int', 176, _

'int', 154, _

'hwnd', $gui_Main, _

'hwnd', 0, _

'int', $h_Instance, _

'ptr', '')

GUISetState()

While 1

$gm = GuiGetMsg()

If $gm = $GUI_EVENT_CLOSE Then ExitLoop

WEnd

Just a quick and simple little calendar utility.

Edited by Saunders

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...