in a typical sdk-style application, the message pump usually resides in the pbmain function (although it does not have to be there, it is usually placed there by convention).
the translateaccelerator() api converts the keystoke messages taken from the applications message queue and converts them into %wm_command messages and dispatches them. the window or dialog procedure (callback) acts upon these %wm_command messages exactly as if the user had triggered the menu item itself.
the premise is that the message pump loop must run for the duration of the gui portion the application. a typical message pump loop (as per above) will only terminate when it receives a %wm_quit message from the queue. the remaining messages that this loop dispatches are sent to the appropriate control or window procedure as will be determined by the message itself.
therefore, you do not place a message pump "in line" with normal code, since that would break the event driven gui programming model (although there are a few exceptions to this rule, waiting for keystrokes is not one of the exceptions).
basically, event driven code must be constructed quite differently to a procedural code. a typical example is the pbnote.bas example shipped with pb/dll.
for more information on sdk-style programming concepts, please refer to the list of recommended titles at http://www.powerbasic.com/support/pb...hread.php?t=39
------------------
lance
powerbasic support
mailto:[email protected][email protected]</a>
Announcement
Collapse
No announcement yet.
HOW TO CREATE A ".RES" FILE
Collapse
X
-
Guest repliedOriginally posted by Jules Marchildon:
Oops! and one more thing...
In WinMain
Code:ghAccel = LoadAccelerators(hInstance, "MENUACCEL") ...etc While IsTrue(GetMessage(Msg, %NULL, 0, 0)) If IsFalse(TranslateAccelerator(ghWnd, ghAccel, Msg)) Then '<-- include this in your message pump! TranslateMessage Msg DispatchMessage Msg End If Wend
Thank you, I'l try your code. I think I goofed. I was thinking
accelerator keys would work like pb20cc "inkeys" but I guess it
is just for the menu?
Thanks,
BRENT
------------------
Leave a comment:
-
Oops! and one more thing...
In WinMain
Code:ghAccel = LoadAccelerators(hInstance, "MENUACCEL") ...etc While IsTrue(GetMessage(Msg, %NULL, 0, 0)) If IsFalse(TranslateAccelerator(ghWnd, ghAccel, Msg)) Then '<-- include this in your message pump! TranslateMessage Msg DispatchMessage Msg End If Wend
Leave a comment:
-
Code:#include "resource.h" // Menu message ID's #define IDM_OPEN WM_USER + 1000 // Open File #define IDM_SAVE IDM_OPEN + 1 // Save #define IDM_EXIT IDM_SAVE + 1 // Exit #define IDM_RUN IDM_EXIT + 1 // Run #define IDM_ANIMATE IDM_RUN + 1 // Anitmate #define IDM_STOP IDM_ANIMATE + 1 // Stop #define IDM_STEP IDM_STOP + 1 // Step #define IDM_CONNECT IDM_STEP + 1 // Connect #define IDM_TILE IDM_CONNECT + 1 // Tile Windows #define IDM_ARRANGE IDM_TILE + 1 // Arrange Icons #define IDM_CODE IDM_ARRANGE + 1 // View Code Window #define IDM_MEMORY IDM_CODE + 1 // View Memory Window #define IDM_CPU IDM_MEMORY + 1 // View CPU Window #define IDM_PORTS IDM_CPU + 1 // View IO Port Window #define IDM_HELP IDM_PORTS + 1 // Help #define IDM_ABOUT IDM_HELP + 1 // About // Accelerator keys for the main menu MENUACCEL ACCELERATORS LOADONCALL MOVEABLE BEGIN "O", IDM_OPEN, VIRTKEY, CONTROL "C", IDM_SAVE, VIRTKEY, CONTROL "R", IDM_RUN, VIRTKEY, CONTROL "A", IDM_ANIMATE, VIRTKEY, CONTROL "T", IDM_STOP, VIRTKEY, CONTROL "S", IDM_STEP, VIRTKEY, CONTROL VK_F1, IDM_HELP, VIRTKEY "A", IDM_ABOUT, VIRTKEY, CONTROL END
Regards,
Jules
Leave a comment:
-
HOW TO CREATE A ".RES" FILE
I had trouble remembering how to creat a .res file for a Icon.
So, after I figured it out, I took a few notes that should help
anyone interest in putting icons on IMGBUTTON in there dialog.
HOW TO CREATE A .RES FILE 2-20-01
1. LOCATE A ICON THAT YOU WANT TO USE.
EX: c:\PBDLL60\SAMPLES\TRAY\FACE3.ICO
2. COPY FACE3.ICO TO THE DIR WERE YOUR PROGRAM IS LOCATED.
3. OPEN DOS FULL SCREEN. TYPE EDIT AT THE DOS PROMPT.
4. SAVE AS "IMAGES1.RC" IN THE DIR WERE YOUR PROGRAM IS LOCATED.
5. TYPE ON FIRST LINE A NAME FOR TYPE OF IMAGE "ICON ICO" PLUS THE
FILE YOU WANT TO USE "FACE3.ICO".
EX: ICON1 ICON FACE3.ICO. THEN SAVE FILE IMAGES1.RC
6. GO TO DIR "C:\PBCC20\BIN" OR C:\PBDLL60\BIN" AND FIND THE FILES
RC.EXE AND PBRES.EXE. YOU NEED THE 32 BIT OR LARGEST FILE OR IT
WILL NOT WORK.
7. COPY RC.EXE AND PBRES.EXE TO THE DIR WERE YOUR PROGRAM IS LOCATED.
8. CHANGE DIR TO YOUR PROGRAM DIR AND AT THE DOS PROMPT, TYPE
RC IMAGES1. THIS WILL CREATE IMAGES1.RES
9. NOW AT DOS PROMPT, TYPE PBRES IMAGES1. THIS WILL CREATE IMAGES.PBR
10. IN YOUR PROGRAM AT TOP ADD #RESOURCE "IMAGES1.PBR" WITH THE
CORRECT PATH.
EX: #COMPILE EXE
#REGISTER NONE
#RESOURCE "C:\DIR\IMAGES1.PBR"
11. YOU WILL NOW HAVE TO GIVE THE IMAGES1 FILE A %ID, JUST LIKE YOU DO
FOR ANY CONTROL ADD BUTTONS, ETC. EX: %IDI_ICON1 = 101
12. IN YOUR CODE WERE YOU PUT - CONTROL ADD IMGBUTTON, AFTER %IDI_ICON1,
TYPE "ICON1" FOR THE NAME.
EX: CONTROL ADD IMGBUTTON,hDlg&,%IDI_ICON1,"ICON1",34,250,40,40,0
13. GLOBAL VARIABLE WILL BE EX: GLOBAL hInstance AS LONG.
14. IN FUNCTION WINMAIN ADD:
REGISTER hDlg AS LONG
LOCAL hIcon AS LONG
hInstance = hCurinstance
' set icon
hIcon = LoadIcon(hInstance,"ICONMAIN")
DIALOG SEND hDlg, %WM_SETICON, %ICON_BIG, hIcon
15. IT SHOULD WORK - GOOD LUCK - THIS IS FOR WINDOWS 98
Hope this helps.
Does anyone know how to create a .res file for ACCELERATOR KEYS?
Thanks,
Brent
------------------
[This message has been edited by BRENT M. GARDNER (edited February 20, 2001).]Tags: None
Leave a comment: