Welcome, Guest. Please login or register.
July 31, 2010, 08:01:46 PM
Home Help Search Login Register
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base

Qbasicnews.com  |  General  |  General/Misc  |  Topic: Very early GUI stuff « previous next »
Pages: [1] 2 3 Print
Author Topic: Very early GUI stuff  (Read 4133 times)
adosorken
*/-\*
*****
Posts: 3654



WWW
Very early GUI stuff
« on: December 19, 2004, 11:03:21 AM »



Working command button.
Logged

'd knock on wood, but my desk is particle board.
VonGodric
Ancient Guru
****
Posts: 674



WWW
Very early GUI stuff
« Reply #1 on: December 19, 2004, 11:25:07 AM »

can you make it XP'ish?
Logged

url]http://fbide.sourceforge.net/[/url]
adosorken
*/-\*
*****
Posts: 3654



WWW
Very early GUI stuff
« Reply #2 on: December 19, 2004, 11:26:30 AM »

Don't know yet. Still experimenting. I'm surprised I even got it to work in the first place. Cheesy
Logged

'd knock on wood, but my desk is particle board.
fsw
Guru
**
Posts: 251



Very early GUI stuff
« Reply #3 on: December 19, 2004, 03:26:53 PM »

Quote from: "VonGodric"
can you make it XP'ish?

To get this to work you need to have a 'myapp.exe.manifest' file with the following text:
Code:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="X86"
name="CompanyName.ProductName.YourApp"
type="win32"
/>
<description>Your application description here.</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>

the fields don't need to be set with your apps infos.
The bad thing about this external file is:
if the manifest file is corrupted your application won't start at all.
You have to delete the manifest file first.

Better is to have the manifest file converted to a resource with this setting (normally a myapp.rc file):
Code:

1 24 "WindowsXP.Manifest"

where WindowsXP.Manifest is the name of the xml file, and have it linked into the exe.
Logged
CGI Joe
Member
*
Posts: 61



Very early GUI stuff
« Reply #4 on: December 21, 2004, 04:08:12 PM »

Er, that's for .NET apps

Unless I'm missing something here.
Logged
adosorken
*/-\*
*****
Posts: 3654



WWW
Very early GUI stuff
« Reply #5 on: December 21, 2004, 11:59:09 PM »

Welp, I got command buttons almost fully working, although not yet XP-style. The only problem from here is going to be making some kind of abstraction layer. I've not yet gotten tab-focus working, but command buttons can be placed and activated. Of course, it's really friggin hard to do this kind of work when I only have on average about 2 hours of "free time" per day. Next week, things will be settled down, but this week is absolute hell as far as work goes so there's not going to be a whole lot of progress on this particular project. Oh...and I almost have the little help icon in the titlebar working too. Cheesy

Two working buttons of different styles, plus a combobox in its barest form. Cheesy

...and you're correct CGI Joe, that stuff is for .net and wouldn't have any effect here in FB.
Logged

'd knock on wood, but my desk is particle board.
fsw
Guru
**
Posts: 251



Very early GUI stuff
« Reply #6 on: December 22, 2004, 12:26:22 PM »

Quote from: "adosorken"

...and you're correct CGI Joe, that stuff is for .net and wouldn't have any effect here in FB.

Are you refering to what I posted?

If so, than I'm sorry, because the 2 ways I described are exactly how it works on WinXP (without the .net stuff)
I've done it for years.


QUESTION: has anybody a working CreateFile/OpenFile/ReadFile (win api) example working?
Somehow the compiler tells me some errors because I used:
Code:
ReadFile (hFile, pBuffer, NumBytes, pBytesRead, 0)

the zero was not accepted.
had to change this line:
Code:
Declare Function ReadFile Lib "kernel32" (ByVal hFile As Integer, lpBuffer As ANY, ByVal nNumberOfBytesToRead As Integer, lpNumberOfBytesRead As Integer, lpOverlapped As ANY )  As Integer 'OVERLAPPED) As Integer

in kernel32.bi.
The last parameter IS OVERLAPPED type - but the compiler doesn't accept a zero (regarding Win32 help you can use both for different purposes).
In Dev-Cpp it works as OVERLAPPED type and zero...

What's going on?
Logged
fsw
Guru
**
Posts: 251



Very early GUI stuff
« Reply #7 on: December 22, 2004, 12:31:57 PM »

Quote from: "adosorken"
Welp, I got command buttons almost fully working, although not yet XP-style.


You can add:
Code:
   SendMessage ( hWnd, WM_SETFONT, GetStockObject(DEFAULT_GUI_FONT),0)

after creating your controls (hWnd is the handle of your control).
This way you get the normal GUI font (instead of the bold system font)  Tongue
Logged
fsw
Guru
**
Posts: 251



Very early GUI stuff
« Reply #8 on: December 22, 2004, 02:43:18 PM »

Just wanted to let you know that I tested what I said above and it works even with fb  Shocked

Example:
take the winhello.bas example file and add this:
Code:

    hButton = CreateWindowEx (0, "Button", "Button 1", WS_CHILD OR WS_VISIBLE, 10, 10, 100, 20, hWnd, 0, 0, 0)

before this:
Code:

    ShowWindow   hWnd, iCmdShow
    UpdateWindow hWnd


save the bas file.

Now create a winhello.exe.manifest file with the information that I posted above (the xml code).
Start winhello.exe
That's it.

If you delete winhello.exe.manifest (or rename it) than you will have a classic button.

Now the last thing to do, is to add the winhello.exe.manifest with ID 24 as a resource to the exe.
Because if winhello.exe.manifest is corrupted or not a proper xml file, than you will see nothing.

As a test copy the winhello.exe binary file to winhello.exe.manifest.
Now start winhello.exe
You get a windows error message: "Error executing program!"
That's it because winhello.exe.manifest is now a binary file without xml information.
Winhello.exe won't start anymore.
Delete winhello.exe.manifest.
Now start winhello.exe, it has a classic button.

BTW: Like I said above, for a standard button font add this:
Code:

    SendMessage ( hButton, WM_SETFONT, GetStockObject(DEFAULT_GUI_FONT),0)

after the buttoncreation.
The value of the DEFAULT_GUI_FONT constant is 17.
Actually this:

Code:

UNSPECIFIED_FONT         = 15
DEFAULT_GUI_FONT         = 17


should be added to gdi32.bi

Take care
Logged
adosorken
*/-\*
*****
Posts: 3654



WWW
Very early GUI stuff
« Reply #9 on: December 23, 2004, 12:41:20 AM »

My buttons disappear (in fact, all the controls disappear) when I use the manifest file. Sad

EDIT: Okay, nevermind...I think I found out why. Gonna test said theory right away. Cheesy

EDIT 2: Yup, the theory was correct. In order to use a manifest file, you first have to initialize the common controls. Hence:

Viola! XP-style controls.

Thanks again for this information man...at first I wasn't sure what you were refering to but I'd seen it in .net so it made sense that it'd be a .net-specific issue, but I'm glad it isn't. In any event, this really helps out a lot.
Logged

'd knock on wood, but my desk is particle board.
adosorken
*/-\*
*****
Posts: 3654



WWW
Very early GUI stuff
« Reply #10 on: December 23, 2004, 02:16:07 AM »

Okay, I got a couple of questions for anyone out there who's got some experience in raw GUI programming:

1. The combobox will not display the dropdown icon, although it will function as normal when I send messages to add new text items, and I can scroll through the items using the keyboard's cursor keys. Do I have to draw this in myself? The MSDN makes no mention of it...in fact, as usual, it's quite vague on the subject.
2. With editboxes, there are no scrollbars, even when multiline and the scroll types are set. I see this on the MSDN: "Multiline edit controls can have scroll bars. An edit control with scroll bars processes its own scroll bar messages.". Maybe I'm a bleedin' idiot, but this doesn't make a whole lot of sense to me. Can someone explain wtf I have to do to get scrollbars in editboxes in plain English? Cheesy

In any event, I got more controls working...somewhat. As before, I still don't have a lot of time to work on this so it's mainly just pick and tear at what I can, but here's a newer screenie:

With all of this working to some exent thus far, I've already conceptualized a method of GUI abstraction that hopefully will work. Once the controls are brought "under control", so to speak, it can be created so everyone can have true event-based GUI support under FreeBASIC.

EDIT: New user32.bi released (v1.05, includes new combobox message constants, allowing stuff like adding items to comboboxes), and allfbapi was updated.
Logged

'd knock on wood, but my desk is particle board.
fsw
Guru
**
Posts: 251



Very early GUI stuff
« Reply #11 on: December 23, 2004, 04:56:23 PM »

For the comboBox use this style: CBS_DROPDOWNLIST OR WS_VSCROLL OR CBS_SORT

It works for me...
Logged
fsw
Guru
**
Posts: 251



Very early GUI stuff
« Reply #12 on: December 23, 2004, 05:02:10 PM »

For the editbox use this style:  ES_MULTILINE OR ES_AUTOHSCROLL OR ES_AUTOVSCROLL OR WS_TABSTOP OR WS_VSCROLL OR ES_LEFT

It works for me...
Logged
adosorken
*/-\*
*****
Posts: 3654



WWW
Very early GUI stuff
« Reply #13 on: December 23, 2004, 07:30:35 PM »

Ah okay, it was the WS_VSCROLL that did the trick. Thanks. Cheesy
Logged

'd knock on wood, but my desk is particle board.
adosorken
*/-\*
*****
Posts: 3654



WWW
Very early GUI stuff
« Reply #14 on: December 28, 2004, 10:19:38 AM »

Hey fsw...I tried your example with the manifest included into the resource file, and it seems to crash res2coff. I think for now, FB apps might have to be stuck with .manifest files. Cheesy Unless you know of a way to make this stuff work...
Logged

'd knock on wood, but my desk is particle board.
Pages: [1] 2 3 Print 
Qbasicnews.com  |  General  |  General/Misc  |  Topic: Very early GUI stuff « previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC
SMF Theme © Gaia, Hosting by Employers Job Post
Valid XHTML 1.0! Valid CSS!