PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: question about opening the templates within winfbe  (Read 211 times)

veltesian

  • Little Newbie
  • *
  • Posts: 47
question about opening the templates within winfbe
« on: August 14, 2020, 01:03:13 AM »

hello everyone....

i was wondering if to add a control event (button1_click/mousedown/etc)
to the already compiled template,... would it be just as easy as typing the
frmMain_button1_click() within the template that would just give it function.

in the winfbe template folder, the button creation demo has the following:

' // Adds a button
   pWindow.AddControl("Button", , IDCANCEL, "&Close", 350, 250, 75, 23)

i'm still not understood about how to change the above info to reflect a function
other than being a close/cancel button even by looking at the helpview pages.

i just looked at a project i just saved to use of a button CTRL and i saw the following:


CASE WM_LBUTTONDOWN
         MessageBoxW(GetParent(hwnd), "Click", "FreeBasic", MB_OK)
         EXIT FUNCTION

MessageBoxW(GetParent(hwnd), "Click", "FreeBasic", MB_OK) <---- this line would seem to be where
i would have to insert a custom function.... otherwise i don't really know how to change it. would
it be just as easy as inserting the controls event into that area perhaps with a pointer/linkage/sub ?






« Last Edit: August 14, 2020, 01:12:23 AM by veltesian »
Logged

philbar

  • Little Newbie
  • *
  • Posts: 18
Re: question about opening the templates within winfbe
« Reply #1 on: August 14, 2020, 04:49:42 AM »

Hi, veltesian.

The templates in the "Open New" section of WinFBE are demonstrations of how to use some individual facet of Josť Roca's WinFBX framework to make what I've been calling a "raw" Windows program. Strictly speaking, they're not raw: Josť has done an absolutely amazing job of making a civilized world out of the messy set of a thousand or so functions that access the Windows operating system -- what's known as the API, Application Program Interface. But still, they are not for amateurs.

WinFBX is the engine that drives the Visual Designer in WinFBE. You've already noticed that the programs in the templates don't look anything like the ones you write with the designer. You can't mix them together.

I strongly recommend that you stick to programs written with the project manager and the Visual Designer until you're comfortable that you can make a program do what you want by taking controls out of the Toolbox, placing them on the page, setting the options for each one, choosing the events that each control needs to respond to, and then writing code for each chosen event that makes the controls do the job you've set for yourself. Believe me, there are plenty of tools there for writing useful and amusing programs. Personally, I focus on the amusing ones until I'm forced to do something useful.

Here's a silly program that you can do to teach yourself about properties and remembering the state of something from one event to the next:
  • Put four label controls on a page. Arrange then so they look nice. Set the text in each control to "zero", "one", "two", "three", respectively.
  • Add a button labelled "Next" and give it a Click event.
  • Each time the button is clicked, change the background color of the current box to green and set the background color of the next one to yellow. When you get to box 3, the next one is 0.
Maybe useful suggestion: look up the MOD function in the FreeBasic documentation.
Another useful suggestion: what's the difference between DIM and STATIC?

Second program: take out the button and put in a Timer that will do the same thing twice per second. If it doesn't start working immediately, ask yourself what property of a Timer makes it tick?
Logged

Josť Roca

  • Guru Member
  • *****
  • Posts: 3282
Re: question about opening the templates within winfbe
« Reply #2 on: August 14, 2020, 11:12:10 AM »

The templates were written to teach you how to use the GUI elements of the WinFBX framework coding by hand. Believe it or not, some guys like me prefer to code by hand, probably because I never have used VB6 in the past. Using a visual designer without having learned first how to do it by hand is like if you never had learned how to do addition, substraction, multiplication, division, etc., by hand and only know how to do it using a calculator. I know by experience that to learn Windows programming using the API is hard and requires many time, but it makes the difference between becoming a truly Windows programmer or a tools user. If Paul didn't know how to code using the Windows API, he couldn't have written its visual designer.

veltesian

  • Little Newbie
  • *
  • Posts: 47
Re: question about opening the templates within winfbe
« Reply #3 on: August 14, 2020, 01:52:19 PM »

hello philbar & jose

for philbar ... & sure everyone else if they like ... a file upload as suggested by philbar
enjoy !

and to jose thanks for sharing that with me ... its certainly appreciated.
Logged

philbar

  • Little Newbie
  • *
  • Posts: 18
Re: question about opening the templates within winfbe
« Reply #4 on: August 14, 2020, 06:23:30 PM »

There you go -- that works.

Personally, I'd just give myself an integer variable to keep count, rather than use all the horsepower of a textbox just to count from 1 to 5.

Code: [Select]

static as Long kount
kount = kount + 1
... et cetera

You reminded me of a program I wrote a long time ago. I put the administration section that ordinary users aren't supposed to fool with down below the horizon where nobody would see it unless they really were looking for it.

Josť has a point, of course. No matter how good a designer is, it has to make a compromise between easy and thorough. If every feature of the operating system were available to choose from, you'd have to know about all of them, and then what's the point? It's like the difference between driving with a stickshift or an automatic. Thanks to WinFBX, the stickshift is on a sports car and not a dump truck. Still, there's something about the message loop that makes my eyes glaze over.

Logged

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9313
  • Windows 10
    • PlanetSquires Software
Re: question about opening the templates within winfbe
« Reply #5 on: August 14, 2020, 09:42:47 PM »

Personally, I'd just give myself an integer variable to keep count, rather than use all the horsepower of a textbox just to count from 1 to 5.

I agree 100%

Code: [Select]
''
''
Function Form1_Button1_Click( ByRef sender As wfxButton, ByRef e As EventArgs ) As LRESULT
   
   static as long nCount
   nCount += 1
   
   if nCount > 4 then nCount = 1
   
   select case nCount
      case 1
         Form1.z1.BackColor = BGR(50,180,0)
         Form1.z2.BackColor = BGR(250,250,0)
         Form1.z3.BackColor = BGR(240,240,245)
         Form1.z4.BackColor = BGR(240,240,245)
 
      case 2
         Form1.z1.BackColor = BGR(240,240,245)
         Form1.z2.BackColor = BGR(50,180,0)
         Form1.z3.BackColor = BGR(250,250,0)
         Form1.z4.BackColor = BGR(240,240,245)
   
      case 3
         Form1.z1.BackColor = BGR(240,240,245)
         Form1.z2.BackColor = BGR(240,240,245)
         Form1.z3.BackColor = BGR(50,180,0)
         Form1.z4.BackColor = BGR(250,250,0)
   
      case 4
         Form1.z1.BackColor = BGR(250,250,0)
         Form1.z2.BackColor = BGR(240,240,245)
         Form1.z3.BackColor = BGR(240,240,245)
         Form1.z4.BackColor = BGR(50,180,0)
    end select

Function = 0
End Function   
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

veltesian

  • Little Newbie
  • *
  • Posts: 47
Re: question about opening the templates within winfbe
« Reply #6 on: August 14, 2020, 10:26:13 PM »

thanks to paul & philbar for showing me these other things (static variable/etc)
that i had not considered before using a static variable but after consideration i do
believe i will. i would agree that instead of using a textbox for such a small number
count, a procedure/sub routine would serve me better with usage of a static variable.
i would really like to learn as much as i can & in time where i would start a new
project i would then choose to take a stroll further into the language so i can understand
by what a certain new programming code would do or how it could work with the
idea @ hand in that moment of creation.

thanks again. i'd certainly appreciate any/all other thoughts or comments on how i could
further improve on coding in the future. perhaps this could seriously expand what i do know.




« Last Edit: August 14, 2020, 11:14:09 PM by veltesian »
Logged