Software Archive
Read-only legacy content
17061 Discussions

Toolbars in Fortran Win Apps

Deleted_U_Intel
Employee
1,092 Views
Hi,

I am looking for infor on incorporating a toolbar into Fortran
Win Apps. Even info about about doing it in C with the WinApi
is welcome. All I can find currently is about using MFC to do the
Toolbar.

ML Clark
0 Kudos
7 Replies
Jugoslav_Dujic
Valued Contributor II
1,092 Views
Um, David Graham (DavidGrahamMason) and I (j.dujic) had a rather detailed discussion on that in the old Forum (forum.compaq.com) called, as I recall, "Toolbars" or "Visual Fortran - Toolbars". That was in October or so. So, please try to search there first - if the old forum is still alive - and if you don't succeed, please let me know so I'll try to answer tomorrow (I have a sample, but it is rather large, and it would require some time to reduce it to a more readable form). Unfortunately, I did not keep the old posts (hoped they will be always available at Compaq's site :-( )Perhaps David has one ready?

Furthermore, the toolbars are rather thoroughly described in Win32 SDK help (User Interface Services/Common Controls/Toolbars) with some samples in C. That would be a good place to start searching.

Regards,

Jugoslav
0 Kudos
Intel_C_Intel
Employee
1,092 Views
I don't know what's wrong, but I've tried twice to respond to this thread, but the message doesn't show up. :-
Maybe my post was too long. Is there a message limit?

Anyway, to keep the message short, here's two threads from the old forum (9/2000) that I tried to post here; subjects:
"How do I get a tool bar in application"
"Problem with tool bar buttons"

When I get some free time, I'm thinking of making a pdf of the messages I've archived and posting it. I'm open to suggestions.

-John
0 Kudos
davidgraham
Beginner
1,092 Views
I posted a reply this morning - with an example, it has not appeared yet, I have posted it again.

Steve is there a problem with long messages?

David
0 Kudos
Intel_C_Intel
Employee
1,092 Views
Re: Old messages

Here are clippings from two threads from the old message board in Sept 2000.
- "How do I get a tool bar in application "
- "Problem with tool bar buttons"

FYI, once I get some free time, I plan on collecting the messages I've clipped from the old forum, dumping them into a pdf file and posting it. If you have another idea, let me know.

I started collecting messages when news of the impending forum upgrade was announced, just in case portability was less than expected. I have messages of some interest (to me, I guess) from #1256 to #5839.

Here's the toolbar stuff:

Topic: Fortran Message #4988
Subject: How do I get a tool bar in application
From: DavidGrahamMason 09/08/00 10:20:05

I have just noticed that Insert|Resource allows you to insert a tool bar.

I can create buttons, with nice images but how do I display the bar in my application?

I have a Windows application based on the 'Generic' example with a menu but I would like to add a tool bar.

Thanks,

David

------------------------------------------------------------

Topic: Fortran Message #4996
Subject: RE: How do I get a tool bar in application
From: j.dujic 09/09/00 05:59:27

Hi David,
Here's the sample code (taken from a real application
and a bit shortened) illustrating Toolbar creation.
In order to have it functional, you have to process
WM_COMMAND message and take appropriate action on
LOWORD(wParam). The sample code also contains tooltips
(TBSTYLE_TOOLTIPS):

!===============================================
SUBROUTINE CreateAdToolbar()

USE MSFWIN
USE REGISTRY !(My local module)
USE TOOLBAR !(My local module)
IMPLICIT INTEGER(h-n)
IMPLICIT LOGICAL(b)

INCLUDE 'RESOURCE.FD'

INTEGER,PARAMETER:: jBitmap(4)=(/0,0,1,2/)
INTEGER,PARAMETER:: jdCommand(4)= &
(/ID_BUTTON_INFOOK,0,ID_BUTTON_ERR,ID_BUTTON_MAKAZE/)

DO i=1,4
FButton(i)%iBitmap=jBitmap(i)
FButton(i)%idCommand=jdCommand(i)
FButton(i)%fsState=TBSTATE_ENABLED
FButton(i)%dwData=0
FButton(i)%iString=0
END DO
FButton(1)%fsStyle=TBSTYLE_BUTTON
FButton(2)%fsStyle=TBSTYLE_SEP
FButton(3)%fsStyle=TBSTYLE_CHECK
FButton(4)%fsStyle=TBSTYLE_CHECK
FButton(4)%fsState=TBSTATE_INDETERMINATE
hInfoToolbar=CreateToolbarEx(hFrame,WS_CHILD.OR.TBSTYLE_TOOLTIPS.OR. &
WS_BORDER,IDR_TOOLBAR_INFO,5,hInst,IDR_TOOLBAR_INFO,LOC(FButton), &
4,0,0,16,15,20)
iSt=ShowWindow(hInfoToolbar,.FALSE.)

END SUBROUTINE CreateAdToolbar
!===============================================
REMARKS:
1) The sample code creates a toolbar with three
buttons, with separator between 1st and 2nd. Separator
is treated like any other button. 3rd and 4th act
like "check-buttons", i.e. similar to check boxes
2) jBitmap contains zero-based indices of bitmaps
in the toolbar you create. So, 1st button has 0-th
bitmap, 2nd is separator (bitmap is ignored), 3rd
1-st bitmap etc. Note that bitmaps need not appear in
the same order as in the bitmap created in rc editor.
3) The code is written for CVF5. I think that with CVF6 you should pass just FButton instead of LOC().
4) You can even add "standard" bitmaps from a system
resource (like Open, Save, etc.). I prefer to capture
those from an application that has them (PrintScreen
key, paste them into Paint, and then cut them into
rc editor.)
5) Please see "Toolbars" section of SDK help for
explanation of constants, messages and functions
used for toolbars.
Tooltips are a bit complicated issue, so if you
want'em, pls post a reply.
hth
jdujic@uns.ns.ac.yu

------------------------------------------------------------
Topic: Fortran Message #5007
Subject: RE: How do I get a tool bar in application
From: DavidGrahamMason 09/11/00 05:30:08

dujic,

Thanks for your reply.
I have now got the too
0 Kudos
Intel_C_Intel
Employee
1,092 Views
Re: Old messages

Here are clippings from two threads from the old message board in Sept 2000.
- "How do I get a tool bar in application "
- "Problem with tool bar buttons"

FYI, once I get some free time, I plan on collecting the messages I've clipped from the old forum, dumping them into a pdf file and posting it. If you have another idea, let me know.

I started collecting messages when news of the impending forum upgrade was announced, just in case portability was less than expected. I have messages of some interest (to me, I guess) from #1256 to #5839.

Here's the toolbar stuff:

Topic: Fortran Message #4988
Subject: How do I get a tool bar in application
From: DavidGrahamMason 09/08/00 10:20:05

I have just noticed that Insert|Resource allows you to insert a tool bar.

I can create buttons, with nice images but how do I display the bar in my application?

I have a Windows application based on the 'Generic' example with a menu but I would like to add a tool bar.

Thanks,

David

------------------------------------------------------------

Topic: Fortran Message #4996
Subject: RE: How do I get a tool bar in application
From: j.dujic 09/09/00 05:59:27

Hi David,
Here's the sample code (taken from a real application
and a bit shortened) illustrating Toolbar creation.
In order to have it functional, you have to process
WM_COMMAND message and take appropriate action on
LOWORD(wParam). The sample code also contains tooltips
(TBSTYLE_TOOLTIPS):

!===============================================
SUBROUTINE CreateAdToolbar()

USE MSFWIN
USE REGISTRY !(My local module)
USE TOOLBAR !(My local module)
IMPLICIT INTEGER(h-n)
IMPLICIT LOGICAL(b)

INCLUDE 'RESOURCE.FD'

INTEGER,PARAMETER:: jBitmap(4)=(/0,0,1,2/)
INTEGER,PARAMETER:: jdCommand(4)= &
(/ID_BUTTON_INFOOK,0,ID_BUTTON_ERR,ID_BUTTON_MAKAZE/)

DO i=1,4
FButton(i)%iBitmap=jBitmap(i)
FButton(i)%idCommand=jdCommand(i)
FButton(i)%fsState=TBSTATE_ENABLED
FButton(i)%dwData=0
FButton(i)%iString=0
END DO
FButton(1)%fsStyle=TBSTYLE_BUTTON
FButton(2)%fsStyle=TBSTYLE_SEP
FButton(3)%fsStyle=TBSTYLE_CHECK
FButton(4)%fsStyle=TBSTYLE_CHECK
FButton(4)%fsState=TBSTATE_INDETERMINATE
hInfoToolbar=CreateToolbarEx(hFrame,WS_CHILD.OR.TBSTYLE_TOOLTIPS.OR. &
WS_BORDER,IDR_TOOLBAR_INFO,5,hInst,IDR_TOOLBAR_INFO,LOC(FButton), &
4,0,0,16,15,20)
iSt=ShowWindow(hInfoToolbar,.FALSE.)

END SUBROUTINE CreateAdToolbar
!===============================================
REMARKS:
1) The sample code creates a toolbar with three
buttons, with separator between 1st and 2nd. Separator
is treated like any other button. 3rd and 4th act
like "check-buttons", i.e. similar to check boxes
2) jBitmap contains zero-based indices of bitmaps
in the toolbar you create. So, 1st button has 0-th
bitmap, 2nd is separator (bitmap is ignored), 3rd
1-st bitmap etc. Note that bitmaps need not appear in
the same order as in the bitmap created in rc editor.
3) The code is written for CVF5. I think that with CVF6 you should pass just FButton instead of LOC().
4) You can even add "standard" bitmaps from a system
resource (like Open, Save, etc.). I prefer to capture
those from an application that has them (PrintScreen
key, paste them into Paint, and then cut them into
rc editor.)
5) Please see "Toolbars" section of SDK help for
explanation of constants, messages and functions
used for toolbars.
Tooltips are a bit complicated issue, so if you
want'em, pls post a reply.
hth
jdujic@uns.ns.ac.yu

------------------------------------------------------------
Topic: Fortran Message #5007
Subject: RE: How do I get a tool bar in application
From: DavidGrahamMason 09/11/00 05:30:08

dujic,

Thanks for your reply.
I have now got the too
0 Kudos
davidgraham
Beginner
1,092 Views
Here is some code that I developed from dujic's example, it is for CVF v6.5.
The routine CreateToolBAr is called at the begining of WinMain before the message loop.

I used the same ID names for the tool bar buttons and the Menu items as I kept getting problems with the different menu items & tool bar buttons getting the same ID number.

The button presses are processed in the same way as the menu items in the case(WM_COMMAND) section.

I have added part of the tool tips this is taken from the case(WM_NOTIFY) section.

In the help index enter 'toolbar' and it shows lots of information which may help.

Hope this helps you.

David


subroutine CreateToolBar
!------------------------
use COMCTL32
use grad_inc ! for hWndMain

include 'resource.fd'

type (T_TBBUTTON) FButton(50)

integer, parameter:: jBitmap(39)=(/0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21, &
22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38/)
integer, parameter:: jdCommand(39) = &
(/IDM_VIEW_REFRESH,IDM_ZOOM_IN, IDM_ZOOM_OUT, IDM_ZOOM_WINDOW, &
IDM_ZOOM_ALL, IDM_VIEW_PAN, IDM_WINDOW_LAST,IDM_WINDOW_NEXT, &
ID_SEPARATOR1, IDM_UNDO, IDM_REDO, ID_SEPARATOR1, &
IDM_FC, IDM_CHAFC, ID_SEPARATOR1, IDM_INPUT, &
IDM_EDIT, IDM_COPY, IDM_MOVE, IDM_DELETE, &
IDM_RESTOR, ID_SEPARATOR1,IDM_JOIN, IDM_SPLIT, &
IDM_DIVLIN, IDM_OFFSET, IDM_PROJ, IDM_INTCC, &
IDM_INTCL, IDM_INTLL, ID_SEPARATOR1, IDM_CHAHT, &
IDM_LEVTEX, IDM_DELCO, ID_SEPARATOR1, IDM_SETPLT, &
ID_SEPARATOR1, IDM_DIST, IDM_REPORT_FEATURES/)

integer*2 i2
logical*4 lret

DO i2 = 1,39
if (i2 /= 9 .and. i2 /= 12 .and. i2 /= 15 .and. i2 /= 22 .and. i2 /= 31 &
.and. i2 /= 35 .and. i2/=37) then

fButton(i2)%ibitmap = jBitmap(i2)
fButton(i2)%idcommand = jdCommand(i2)
fButton(i2)%fsstate = TBSTATE_ENABLED
fButton(i2)%fsstyle = TBSTYLE_BUTTON
fButton(i2)%dwData = 0
fButton(i2)%iString = 0
else
fButton(i2)%fsstate = TBSTATE_ENABLED
fButton(i2)%fsstyle = TBSTYLE_SEP
fButton(i2)%dwData = 0
fButton(i2)%iString = 0
end if

END DO

hWndToolBar = CreateToolBarEx(hWndMain, WS_CHILD.OR.TBSTYLE_TOOLTIPS.OR. &
WS_BORDER,IDR_TOOLBAR,5,hInst,IDR_TOOLBAR, FButton,&
39,0,0,16,15,20)
lret = ShowWindow(hWndToolbar, SW_SHOW)
end subroutine CreateToolBar

!--------------------------------------------------------------------

type (T_TOOLTIPTEXT) :: TTT;POINTER(lpTTT,TTT)
type (T_NMHDR) :: Header;POINTER(lpHeader,Header)

case (WM_NOTIFY)
lpHeader=lparam
if (Header%Code==TTN_NEEDTEXT) then
lpTTT=lParam
SELECT CASE (Header%idFrom)
CASE (IDM_VIEW_REFRESH)
tip='Refresh View (plot all)'C
CASE (IDM_ZOOM_IN)
tip='Zoom In x2'C
CASE (IDM_ZOOM_OUT)
tip='Zoom Out x2'C
CASE (IDM_ZOOM_WINDOW)
tip='Window Area'C
!etc..

CASE (IDM_PROJ)
tip='Project point'C
CASE (IDM_REPORT_FEATURES)
tip='Report feature'C
CASE (IDM_DIST)
tip='Bearing & Distance'C
END SELECT
TTT%lpszText=loc(tip)
end if
0 Kudos
davidgraham
Beginner
1,092 Views
Here is some code that I developed from dujic's example, it is for CVF v6.5.
The routine CreateToolBAr is called at the begining of WinMain before the message loop.

I used the same ID names for the tool bar buttons and the Menu items as I kept getting problems
with the different menu items & tool bar buttons getting the same ID number.

The button presses are processed in the same way as the menu items in the case(WM_COMMAND) section.

I have added part of the tool tips this is taken from the case(WM_NOTIFY) section.

In the help index enter 'toolbar' and it shows lots of information which may help.

Hope this helps you.

David


subroutine CreateToolBar
!------------------------
use COMCTL32
use grad_inc ! for hWndMain

include 'resource.fd'

type (T_TBBUTTON) FButton(50)

integer, parameter:: jBitmap(39)=(/0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21, &
22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38/)
integer, parameter:: jdCommand(39) = &
(/IDM_VIEW_REFRESH,IDM_ZOOM_IN, IDM_ZOOM_OUT, IDM_ZOOM_WINDOW, &
IDM_ZOOM_ALL, IDM_VIEW_PAN, IDM_WINDOW_LAST,IDM_WINDOW_NEXT, &
ID_SEPARATOR1, IDM_UNDO, IDM_REDO, ID_SEPARATOR1, &
IDM_FC, IDM_CHAFC, ID_SEPARATOR1, IDM_INPUT, &
IDM_EDIT, IDM_COPY, IDM_MOVE, IDM_DELETE, &
IDM_RESTOR, ID_SEPARATOR1,IDM_JOIN, IDM_SPLIT, &
IDM_DIVLIN, IDM_OFFSET, IDM_PROJ, IDM_INTCC, &
IDM_INTCL, IDM_INTLL, ID_SEPARATOR1, IDM_CHAHT, &
IDM_LEVTEX, IDM_DELCO, ID_SEPARATOR1, IDM_SETPLT, &
ID_SEPARATOR1, IDM_DIST, IDM_REPORT_FEATURES/)

integer*2 i2
logical*4 lret

DO i2 = 1,39
if (i2 /= 9 .and. i2 /= 12 .and. i2 /= 15 .and. i2 /= 22 .and. i2 /= 31 &
.and. i2 /= 35 .and. i2/=37) then

fButton(i2)%ibitmap = jBitmap(i2)
fButton(i2)%idcommand = jdCommand(i2)
fButton(i2)%fsstate = TBSTATE_ENABLED
fButton(i2)%fsstyle = TBSTYLE_BUTTON
fButton(i2)%dwData = 0
fButton(i2)%iString = 0
else
fButton(i2)%fsstate = TBSTATE_ENABLED
fButton(i2)%fsstyle = TBSTYLE_SEP
fButton(i2)%dwData = 0
fButton(i2)%iString = 0
end if

END DO

hWndToolBar = CreateToolBarEx(hWndMain, WS_CHILD.OR.TBSTYLE_TOOLTIPS.OR. &
WS_BORDER,IDR_TOOLBAR,5,hInst,IDR_TOOLBAR, FButton,&
39,0,0,16,15,20)
lret = ShowWindow(hWndToolbar, SW_SHOW)
end subroutine CreateToolBar

!--------------------------------------------------------------------

type (T_TOOLTIPTEXT) :: TTT;POINTER(lpTTT,TTT)
type (T_NMHDR) :: Header;POINTER(lpHeader,Header)

case (WM_NOTIFY)
lpHeader=lparam
if (Header%Code==TTN_NEEDTEXT) then
lpTTT=lParam
SELECT CASE (Header%idFrom)
CASE (IDM_VIEW_REFRESH)
tip='Refresh View (plot all)'C
CASE (IDM_ZOOM_IN)
tip='Zoom In x2'C
CASE (IDM_ZOOM_OUT)
tip='Zoom Out x2'C
CASE (IDM_ZOOM_WINDOW)
tip='Window Area'C
etc.

CASE (IDM_PROJ)
tip='Project point'C
CASE (IDM_REPORT_FEATURES)
tip='Report feature'C
CASE (IDM_DIST)
tip='Bearing & Distance'C
END SELECT
TTT%lpszText=loc(tip)
end if
0 Kudos
Reply