Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[AHK_L][Alpha]CGUI - Object-Oriented GUIS!


  • Please log in to reply
151 replies to this topic
fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009

Does not work with AHK_L 1.1.00.00. I do not know which version exactly it requires, but it works perfectly with v1.1.03.00.

It may be helpful to post a version requirement in the top post.


You're right. It requires AHK_L 1.1.01.00 or newer because it uses Instance variables at one or two places.

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
I added an Owner/ToolWindow property that allows to create "tool windows" for parent windows of any process similar to my Tool Window library. It also supports automatic closing when the parent window is closed.

The tasks on my todo list are getting shorter and I think that a first non-alpha version may be released soon.

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
I have implemented ActiveX controls. Here's how it looks like:

Window := new CActiveXDemo("ActiveXDemo")
return
#include <CGUI>
Class CActiveXDemo Extends CGUI
{
	__New(title)
	{
		base.__New()
		this.Title := Title 
		this.Add("ActiveX", "ie", "w800 h600", "Shell.Explorer")
		this.ie.Navigate("http://www.google.com")
		this.DestroyOnClose := true
		this.Show()
	}
	ie_NavigateComplete2(pDisp, URL)
	{
		if(InStr(URL, "google")) ;Prohibit using google :D
			this.ie.Navigate("http://www.microsoft.com")
	}
	PostDestroy()
	{
		if(!this.Instances.MaxIndex()) ;Exit when all instances of this window are closed
			ExitApp
	}
}

I think that's easy enough for using it very conveniently :)

I also changed the way controls are accessed in the GUI.Controls array. Now they are accessed by hwnd rather than by name. This is done so that even subcontrols of other controls (like tab children) can be accessed through the main gui object. Accessing by name is still supported for all top-level controls through the GUI object.

noob1999
  • Members
  • 32 posts
  • Last active: Nov 05 2012 10:12 PM
  • Joined: 14 May 2011

A very simple note-taking app.

Never require a file name, kindof like onenote


Hey, you realize this would be killer if you could have the text shown as in Microsoft Word Outline view, right below the categories, instead of separate box, so you could view and edit everything in one screen, just like Word. You could have a separate categories-only pane, too, just like Word. And drag and drop categories and notes.

Fonts and colors for different levels and normal text should be customizable. And preferably RTF capabilities.

That would be AWESOME.

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009

A very simple note-taking app.

Never require a file name, kindof like onenote


Hey, you realize this would be killer if you could have the text shown as in Microsoft Word Outline view, right below the categories, instead of separate box, so you could view and edit everything in one screen, just like Word. You could have a separate categories-only pane, too, just like Word. And drag and drop categories and notes.

Fonts and colors for different levels and normal text should be customizable. And preferably RTF capabilities.

That would be AWESOME.

That would only allow single line notes though?
Apart from that, you can easily do that in a text processor such as word already :p

The example I posted here was merely meant as a usage example for this library and not as a program that is meant to be used in productive environments.

infogulch
  • Moderators
  • 717 posts
  • Last active: Jul 31 2014 08:27 PM
  • Joined: 27 Mar 2008
noob1999: Even though it's an example script, I'm sure fragman would be more than happy if you took the program and refined it with those suggestions yourself, especially if you reposted it here. :)

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
Sure, go ahead :)

I have implemented window message handling inside of the window objects now:
SetBatchlines, -1
MyWindow := new CWindowMessageDemo() ;Create an instance of this window class
MySecondWindow := new CWindowMessageDemo() ;Create a second instance of this window class
return

#include <CGUI>
Class CWindowMessageDemo Extends CGUI
{
	__New()
	{
		;CGUI constructor should be called before doing anything else
		base.__New()
		this.Title := "Window message demo"
		this.Resize := true
		this.MinSize := "400x300"
		this.Add("Text", "txtX", "x10", "X:")
		this.Add("Edit", "editX", "x+10", "")
		this.Add("Text", "txtY", "x10", "Y:")
		this.Add("Edit", "editY", "x+10", "")
		this.CloseOnEscape := true
		this.DestroyOnClose := true
		this.OnGUIMessage(0x200, "MouseMove")
		this.Show("")
		return this
	}
	MouseMove(Msg, wParam, lParam)
	{
		this.editX.text := lParam & 0xFFFF
		this.editY.text := (lParam & 0xFFFF0000) >> 16
		return 0
	}
}
The example above demonstrates how to register for the WM_MOUSEMOVE message for an individual window and how to use its lParam value. Registering of the real message handling done by OnMessage is completely done behind the scenes and users of this library don't have to worry about it.

sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010

I have implemented window message handling inside of the window objects now:

[...]

The example above demonstrates how to register for the WM_MOUSEMOVE message for an individual window and how to use its lParam value. Registering of the real message handling done by OnMessage is completely done behind the scenes and users of this library don't have to worry about it.


Very nice! I'm *liking* this lib, makes GUI programming so much cleaner and programmatic.

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
Added enter and leave events. Simply implement event functions with names like these in the window class:
- ControlName_Enter()
- ControlName_Leave()

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
I don't see Enter/Leave in the documentation. Do they relate to mouse position or keyboard focus?

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
Sorry, I didn't update the docs yet. They relate to keyboard focus (NM_SETFOCUS and NM_KILLFOCUS to be exact). Renaming them to ControlName_FocusEnter and ControlName_FocusLeave might actually be more appropriate, I just used the C# names for now.

sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010

Sorry, I didn't update the docs yet. They relate to keyboard focus (NM_SETFOCUS and NM_KILLFOCUS to be exact). Renaming them to ControlName_FocusEnter and ControlName_FocusLeave might actually be more appropriate, I just used the C# names for now.


Yes, that is more appropiate. It may be possible with alternatives, but I think FocusEnter and FocusLeave makes more sense. Dunno about you guys, but I think Focus and Unfocus (or FocusOff) makes sense, too.

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
There's a problem related to these messages:
<!-- m -->http://www.autohotke...ic.php?p=475476<!-- m -->

zzzooo10
  • Members
  • 237 posts
  • Last active: Apr 14 2015 01:57 AM
  • Joined: 19 Dec 2010
Sorry if I'm missing something obvious, but how do you add an item to a listview? Ive tried this with no luck.
gui := new Test()

#include <CGUI>

#SingleInstance, Force



Class Test Extends CGUI

{

	__New()

	{

		Base.__New() ;init CGUI

        this.Add("ListView", "randomListView", "", "Keys")

		this.Title := "Test"

		this.DestroyOnClose := true ;By Setting this the window will destroy itself when the user cloeses it

		this.Show()

	}



    randomListView_RightClick(RowIndex)

    {

        this.randomListView.Add("", "Text...")

    }

    

	;Called when the window was destroyed (e.g. closed here)

	PreClose()

	{

		ExitApp

	}

}



Test_randomListView:

CGUI.HandleEvent()

return


fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
If you work with controls that have some kind of list data, you need to work with the single entries by using the Control.Items object:
gui := new Test() 

#include <CGUI> 

#SingleInstance, Force 



Class Test Extends CGUI 

{ 

   __New() 

   { 

      Base.__New() ;init CGUI 

        this.Add("ListView", "randomListView", "", "Keys") 

      this.Title := "Test" 

      this.DestroyOnClose := true ;By Setting this the window will destroy itself when the user cloeses it 

      this.Show() 

   } 



    randomListView_RightClick(RowIndex) 

    { 

        this.randomListView.Items.Add("", "Text...") 

    } 

    

   ;Called when the window was destroyed (e.g. closed here) 

   PreClose() 

   { 

      ExitApp 

   } 

} 



Test_randomListView: 

CGUI.HandleEvent() 

return