Beginner's question

Just starting out? Need help? Post your questions and find answers here.
rolstra
User
User
Posts: 11
Joined: Mon Mar 24, 2008 10:44 pm
Location: Austria

Beginner's question

Post by rolstra »

I am an absolute beginner with Visual Designer and do not have much experience with PB so far. I started my first project:

I created a blank new window with two text gadgets ("The hostname is:" and "The IP-Adress is: ") and two string gadgets (containing hostname and IP-adress). After that the code is displayed in the PB editor: 'GeneratedMainFile.pb' and 'GeneratedIncludeFile.pb'. The project itself is stored as 'Test.pbv'.

GeneratedMainFile.pb:

Code: Select all

; PureBasic Visual Designer v3.95 build 1485 (PB4Code)

IncludeFile "GeneratedIncludeFile.pb"
GeneratedIncludeFile.pb:

Code: Select all

; PureBasic Visual Designer v3.95 build 1485 (PB4Code)


;- Window Constants
;
Enumeration
  #Window_0
EndEnumeration

;- Gadget Constants
;
Enumeration
  #Text_0
  #String_0
  #Text_1
  #String_1
EndEnumeration

Global Dim Language$(1)


Procedure BalloonTip(WindowID, Gadget, Text$ , Title$, Icon)
  
  ToolTip=CreateWindowEx_(0,"ToolTips_Class32","",#WS_POPUP | #TTS_NOPREFIX | #TTS_BALLOON,0,0,0,0,WindowID,0,GetModuleHandle_(0),0)
  SendMessage_(ToolTip,#TTM_SETTIPTEXTCOLOR,GetSysColor_(#COLOR_INFOTEXT),0)
  SendMessage_(ToolTip,#TTM_SETTIPBKCOLOR,GetSysColor_(#COLOR_INFOBK),0)
  SendMessage_(ToolTip,#TTM_SETMAXTIPWIDTH,0,180)
  Balloon.TOOLINFO\cbSize=SizeOf(TOOLINFO)
  Balloon\uFlags=#TTF_IDISHWND | #TTF_SUBCLASS
  Balloon\hWnd=GadgetID(Gadget)
  Balloon\uId=GadgetID(Gadget)
  Balloon\lpszText=@Text$
  SendMessage_(ToolTip, #TTM_ADDTOOL, 0, Balloon)
  If Title$ > ""
    SendMessage_(ToolTip, #TTM_SETTITLE, Icon, @Title$)
  EndIf
  
EndProcedure

Procedure Open_Window_0()
  If OpenWindow(#Window_0, 216, 0, 600, 300, "New window ( 0 )",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
    If CreateGadgetList(WindowID(#Window_0))
      TextGadget(#Text_0, 20, 30, 90, 20, Language$(0))
      StringGadget(#String_0, 140, 30, 190, 20, "")
      TextGadget(#Text_1, 20, 70, 80, 20, Language$(1))
      StringGadget(#String_1, 140, 70, 190, 20, "")
      
    EndIf
  EndIf
EndProcedure

Procedure ReadCatalog(Filename$)
  
  If ReadFile(0, Filename$)
    If ReadString(0) = "Catalog"
      For k=0 To 1
        Language$(k) = ReadString(0)
      Next
    EndIf
    CloseFile(0)
  EndIf
  
EndProcedure

Restore BaseLanguage
For k=0 To 1
  Read Language$(k)
Next

DataSection
BaseLanguage:
  Data$ "The hostname is:"
  Data$ "The IP-Adress is:"
EndDataSection
My question is: How can I display hostname and IP-Adress (two strings coming from another pb-program).

Thanks for your answer
Roland
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

Look in the Network Section of the CHM.

I can show you a real simple way to show what IP you have:

Code: Select all

InitNetwork() 
If ExamineIPAddresses() 
  IP.l = NextIPAddress() 
EndIf 

SetGadgetText(#Text_SERVADDRESS, ""+IPString(IP))
The IPString(###) decodes it for you.

So every time you et a network connection you simply decode it with the IPString(#connectionID#) and you are set.

To understand the network connection ideas... look at the Client/Server programs in examples.

I would suggest starting with a simpler project to learn to do what you want.
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
rolstra
User
User
Posts: 11
Joined: Mon Mar 24, 2008 10:44 pm
Location: Austria

Post by rolstra »

Thank you,

where do I have to place this code - in whicht section of what file? I can see that VD creates 2 files, but how can I make an EXE of those files?
Bye,
Roland
User avatar
bembulak
Enthusiast
Enthusiast
Posts: 575
Joined: Mon Mar 06, 2006 3:53 pm
Location: Austria

Post by bembulak »

Hi,

just some good advices:
first of all learn coding purely in PureBasic. Avoid Visual Designer in first place. You need to know, where and how to write code. I know, it's comfortable to use GUI-Creation-Tools, but you need to learn the basics first. You need to know, what and where the eventloop is, and so on...

You'd better go and search for some tutorials:
http://www.purebasic-lounge.com/
http://www.purearea.net/pb/german/index.htm
http://www.purearea.net/pb/german/tutorials.htm

All in german.

Greetings from Austria. ;)
cheers,

bembulak
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

Yes... bembulak has the right idea. Look at the example programs and see where things go.

Even if you are familiar with programming, using the code output by the VD is a bit difficult to wrap your head around. It is structured well and once you get it. It is blindly easy.

But you have to know how to program first.

Forget most of everything your school computer teacher / hack taught you. (I was one for 10 years!)

Start with something simple. Open a window and make a button do something.

Read other code and the forums... most (not all) are commented well.

Don't try to ask for power hacks if you don't know what to do with them. :wink:

Have fun, be patient, read, ask questions.

If you read some code you may be able to figure out where my code is supposed to be paced. :D
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
Post Reply