• Welcome to Jose's Read Only Forum 2023.
 

toolbar question

Started by Frank Brübach, February 03, 2010, 12:46:33 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Frank Brübach

#15
little work in progress..

now it's possible to open a new cWindow sdk frame by a) "ok" button-click or b) via "icon" at toolbar (here for my example the seventh. icon from left side, woman with dark hair and sunglasses ).

to manage this one I had to make c) "opennewSDK" function and d) include there a "richedit" control, just for fun :)

some important part of my code:  
' ===============================================================================
FUNCTION openNewsdk() AS LONG

      ' // Create an instance of the class
  LOCAL pWindow AS IWindow
  pWindow = CLASS "CWindow"
  IF ISNOTHING(pWindow) THEN EXIT FUNCTION

  ' // Create the main window
  LOCAL hwnd AS DWORD

  hwnd = pWindow.CreateWindow(%NULL, "Frankos SDK cWindow 200 with gradient & Toolbar & RichEdit", %CW_USEDEFAULT, %CW_USEDEFAULT, _
         %CW_USEDEFAULT, %CW_USEDEFAULT, -1, -1, CODEPTR(WindowProc2))

  ' // Change the style of the main window class
  SetClassLong hwnd, %GCL_STYLE, %CS_DBLCLKS OR %CS_HREDRAW OR %CS_VREDRAW

  ' // Add two buttons without position or size (they will be resized
  ' // in the WM_SIZE message).
  pWindow.AddButton(hwnd, %IDOK,     "&Ok2",   0, 0, 0, 0, -1, -1)
  pWindow.AddButton(hwnd, %IDCANCEL, "&Quit2", 0, 0, 0, 0, -1, -1)
  ' // Add a rich edit control
  pWindow.AddRichEdit(hwnd, %IDC_RICHEDIT, "my lovely RichEdit box wit first part of lord of the rings story", 0, 0, 0, 0, -1, -1)

  ' // Force the resizing of the buttons by sending a WM_SIZE message
  SendMessage hwnd, %WM_SIZE, 0, 0

  ' // Default message pump (you can replace it with your own)
  pWindow.DoEvents

END FUNCTION
===============================================================================

FUNCTION WindowProc2 (BYVAL hwnd AS DWORD, BYVAL uMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG

  LOCAL hDC AS DWORD
  LOCAL pPaint AS PAINTSTRUCT
  LOCAL rc AS RECT

  SELECT CASE uMsg

     CASE %WM_COMMAND
        SELECT CASE LO(WORD, wParam)
           CASE %IDCANCEL
              IF HI(WORD, wParam) = %BN_CLICKED THEN
                 SendMessage hwnd, %WM_CLOSE, 0, 0
                 EXIT FUNCTION
              END IF

             CASE %IDOK
              IF HI(WORD, wParam) = %BN_CLICKED THEN
                 openNewsdk()
                 EXIT FUNCTION
              END IF

            END SELECT

     CASE %WM_PAINT
        hDC = BeginPaint(hwnd, pPaint)
        GetClientRect hwnd, rc
        SetBkMode hDC, %TRANSPARENT
        SetTextColor hDC, %GREEN
        DrawText hDC, "Hello, my little new AdamEva Windows!", -1, rc, %DT_SINGLELINE OR %DT_CENTER OR %DT_VCENTER
        EndPaint hwnd, pPaint
        FUNCTION = %TRUE
        EXIT FUNCTION

     CASE %WM_ERASEBKGND
        hDC = wParam
        DrawGradient hwnd, hDC
        FUNCTION = %TRUE
        EXIT FUNCTION

     CASE %WM_SIZE
        IF wParam <> %SIZE_MINIMIZED THEN
           GetClientRect hwnd, rc
           MoveWindow GetDlgItem(hwnd, %IDOK), (rc.nRight - rc.nLeft) - 185, (rc.nBottom - rc.nTop) - 35, 75, 23, %TRUE
           MoveWindow GetDlgItem(hwnd, %IDCANCEL), (rc.nRight - rc.nLeft) - 95, (rc.nBottom - rc.nTop) - 35, 75, 23, %TRUE
           MoveWindow GetDlgItem(hwnd, %IDToolbar), (rc.nRight - rc.nLeft) - 5, (rc.nBottom - rc.nTop) - 5, 75, 23, %TRUE
           MoveWindow GetDlgItem(hwnd, %IDC_RICHEDIT), (rc.nRight - rc.nLeft) - 305, (rc.nBottom - rc.nTop) - 425, 250, 150, %TRUE
        END IF

     CASE %WM_DESTROY
        PostQuitMessage 0
        EXIT FUNCTION

  END SELECT

  FUNCTION = DefWindowProc(hwnd, uMsg, wParam, lParam)

END FUNCTION
' =========================================


perhaps somebody can use it or find this stuff helpful :)

by the way: it wasn't easy to find my little fault and need some time to explore the mistake I've done to add new "windowProc2" function with

CASE %WM_SIZE
        IF wParam <> %SIZE_MINIMIZED THEN
           GetClientRect hwnd, rc
           MoveWindow GetDlgItem(hwnd, %IDOK), (rc.nRight - rc.nLeft) - 185, (rc.nBottom - rc.nTop) - 35, 75, 23, %TRUE
           MoveWindow GetDlgItem(hwnd, %IDCANCEL), (rc.nRight - rc.nLeft) - 95, (rc.nBottom - rc.nTop) - 35, 75, 23, %TRUE
           MoveWindow GetDlgItem(hwnd, %IDToolbar), (rc.nRight - rc.nLeft) - 5, (rc.nBottom - rc.nTop) - 5, 75, 23, %TRUE
           MoveWindow GetDlgItem(hwnd, %IDC_RICHEDIT), (rc.nRight - rc.nLeft) - 305, (rc.nBottom - rc.nTop) - 425, 250, 150, %TRUE
     


to size and realize these buttons and the richedit box, that wasn't very clear for me at the start of coding, as I have defined all

  LOCAL hButton AS DWORD
  hButton = pWindow.AddButton(hwnd, %IDOK,     "&Ok",   0, 0, 0, 0, -1, -1)
  hButton = pWindow.AddButton(hwnd, %IDCANCEL, "&Quit", 0, 0, 0, 0, -1, -1)
  hButton = pWindow.AddButton(hwnd, %IDC_RICHEDIT, "&LORD OF THE RING RICH EDIT INPUT", 0, 0, 0, 0, -1, -1)


with "0" values (numbers), that was new for me ;)

Picture of new cWindow sdk window with toolbar, richedit I add as zipfile with exe file for demo showing.

good night, frank
ps: it's also possible to change the color of "menubar" ? (that's too grey and boring for me)

Frank Brübach

#16
I have forgotten to include a Picture path folder for my Icons in my last cWindow example above, sorry. This example hasn't shown at all Icons, because therefore you need all collected icons in one folder.

Here I show a new example with new Icons and an cute Art_Picture with a woman, all done with gdiplus power :)

one favour: perhaps anybody can test this "AEB_Art" Demo if everything works fine, would be nice to get any feedback.

If you're using Icon Buttons 1,2,7,9 (from left side) you will get more features and Infos ;)
I like combination "cWindow" + "gdiplus" class and want to use this for future examples !

the whole powerbasic code increase to nearly 900 lines, uff, that's too much for me, but I need all these commands for my picture features and cWindow frames ! May be I will find shorter way next week, if I know more about cWindow (popup windows) behaviour or related tricky ways. Learning by doing. Work in progress, good to see how gdiplus works and cWindow. some weeks ago I felt like to go in a dark forrest, but now it's brighter and clearer although new questions around cWindow/gdiplus appear every day new :D

I am interested in graphic works and arts, so I will concentrate myself to these topics. three month ago powerbasic was an absolutely alien child for me, today this nice beast is now a little friend I can train for a serious moment... (take it with humour!)

zip File I add.

nice evening, thanks, frank

Frank Brübach

#17
my task: in my "mdiWindowProc" function I have the simple problem to make a new line (empty, for new text input) after return key for my create MDI child window.

 CASE %IDM_NEW
              IF hwndClient THEN
                 nIdx += 1
                 hMdi = CreateMdiChild("PBFrameClass", hwndClient, "", 0)
                 SetWindowText hMdi, "my MDI Child Window" & STR$(nIdx)
              END IF
              EXIT FUNCTION


1) it's not possible to create a new line by hand via return key for a next new empty line with "pWindow.AddrichEdit" or "pWindow.AddTextBox". there must be missing something important, but what ?

     CASE %WM_CREATE
        ' // Retrieve a reference to the CWindow class from the MDI child window handle
        LOCAL pWindow AS IWindow
        pWindow = CWindow_GetObjectFromWindowHandle(hwnd)
        ' // Create and edit control control
        IF ISOBJECT(pWindow) THEN
           GetClientRect hwnd, rc
        'pWindow.AddRichEdit(hwnd, %IDC_EDIT, "test me :)", 0, 0, rc.nRight, rc.nBottom, _
                           'TextBox
        hEdit = pWindow.AddRichEdit(hwnd, %IDC_RICHEDIT, "test me with more lines and return to start a new line with text :)" & $CRLF & _
               "Text Editor (MDI) and in spe Art_Compiler for 'AEB' itself" & $CRLF & _
               "Text Editor (MDI) and in spe Art_Compiler for 'AEB' itself" & $CRLF & _
               "Text Editor (MDI) and in spe Art_Compiler for 'AEB' itself" & $CRLF & _
               "Text Editor (MDI) and in spe Art_Compiler for 'AEB' itself" & $CRLF & _
               "Text Editor (MDI) and in spe Art_Compiler for 'AEB' itself", 0, 0, rc.nRight, rc.nBottom, _
              %WS_CHILD OR %WS_CLIPCHILDREN OR %WS_VISIBLE OR %ES_MULTILINE OR %WS_VSCROLL OR %WS_HSCROLL OR _
              %ES_AUTOHSCROLL OR %ES_AUTOVSCROLL OR %ES_NOHIDESEL, 0)
           EXIT FUNCTION
        END IF


2) my new opened sdk-window (by icon button) with "pWindow.AddRichEdit" (button 7) hasn't this problem so I suppose it belongs to the mdi child window handling. anybody can help ?

I wish to create simple new text lines in this new mdi child window, nothing more ;)

best regards, frank

José Roca

 
You're missing the %ES_WANTRETURN style.

Frank Brübach

#19
hello.

I am just looking for a simple possibility and command to "stretch" an Image with "gdiplus.inc".
with "gdipImageCTX.inc" that's possible, but not for my example, I would like to use gdiplus features.

Quote
CASE %IDC_STRETCHER
              IF HI(WORD, wParam) = %BN_CLICKED THEN
              'GdipImageCtx_SetImageAdjustment GetDlgItem(hwnd, %IDC_IMAGECTX), %GDIP_IMAGECTX_STRETCH, %TRUE '%IDC_IMAGECTX                  
                 EXIT FUNCTION
              END IF

I cannot mix "GdipImageCtx.inc" with "gdiplus.inc" + "cwindow.inc" for my examples, it doesn't work for me, I have tried this one. I am looking for similar command like:

QuoteGRAPHIC STRETCH hBMP, 0, (0, 0)-(BMPx-1,BMPy-1) TO (49,49)-(449,449)

does anybody has experience with stretching a picture (image) with gdiplus ? does any example or link exist to this problem or feature ? would be nice to find one. I was looking for that around some hours without success.

2) new edit :
sorry, but perhaps I have found a way and can solve this problem with:

QuotehStatus2 = GdipGetImageWidth(pImage2, nWidth)
   hStatus2 = GdipGetImageHeight(pImage2, nHeight)
   hStatus2 = GdipDrawImageRectI(pGraphics2, pImage2, 190, 190, nWidth, nHeight)

I will check if I can scale the image by one button click ;)

many thanks, nice day, Frank

Frank Brübach

#20
topic: gdiplus + stretch (or manipulate image size).
sorry for asking again ;)

I am not gdiplus professional (more newbie with this!) , so I show my current problem.

a) If I load a picture with a new sdk frame and use for example "GDIP_SETPIXEL"

' // Draw the bitmap
  hStatus = GdipDrawImageI(pGraphics, pBitmap, 50, 250)

  ' // Get the width and height of the bitmap
  hStatus = GdipGetImageWidth(pBitmap, nWidth)
  hStatus = GdipGetImageHeight(pBitmap, nHeight)
 
 


I load my picture as well as I wish, all ok. but I load for this stretching a new sdk window. that wasn't my idea. I wanted to change the image in same sdk window frame (cWindow).

next step:

b) how can I stretch this picture in same sdk frame ? I use a button (for example: IDC_IMAGE_STRETCH) try to stretch to another size the image (picture), but therefore I need an own command I suggest.

because after clicking IDC_IMAGE_STRETCH button

     CASE %WM_PAINT
        hDC = BeginPaint(hWnd, ps)
        GDIP_SetPixel hDC
        EndPaint(hWnd, ps)


nothing will change, because in %WM_PAINT statement is defined to show the function of "GDIP_SetPixel" and not more. my idea was to delete whole image after showing this first %WM_PAINT for a second %WM_PAINT with new function (for example) "GDIP_SetPixelStretch hDC". that's nonsense ? ;)

any help would be appreciated. I didn't want to use GdipImageCTX include file , although there is exactly this command with my idea and statement I need for. see my last post.

GdipImageCtx_SetImageAdjustment GetDlgItem(hwnd, %IDC_IMAGECTX), %GDIP_IMAGECTX_STRETCH, %TRUE '%IDC_IMAGECTX      

I am walking in a circle with no exit :)

bye, frank

José Roca

 
The function GDIP_SetPixel draws the image using GdipDrawImageRectI. You can declare a global variable, e.g. bStretched, that you will set to TRUE when you click the button. Then, in the function, use:


IF bStretched THEN
   hStatus = GdipDrawImageRectI(pGraphics, pBitmap, x, y, MyWidth, MyHeight)
ELSE
   hStatus = GdipDrawImageI(pGraphics, pBitmap, x, y)
END IF


Where x, y, MyWidth and MyHeight specify the rectangular area where the image will be draw stretched.

Frank Brübach

#22
thanks a lot for you help, josé! I will include this one for my new stretch pictures :)

in general: may I ask you about an optimazing code topic? What is the advantage about/between using sdk frame like cWindow.inc for example to an usual "ddt dialog" (new dialog) editor for popup or loading/saving pictures menus ? I am asking myself it's necessary to use more sdk window frames to bloat my codes. my art editor increases a  lot of lines, be sure ;)

there is any "disadvantage" of using sdk (I think there is factor * 3 in code lines for usual ddt frame code) for application speed ? it's a serious question to run an application. I think you know what I mean.

my idea is to launch an "Art_Editor" for pictures/Images using cWindow and gdiplus features. my idea is to create a picture manipulation software and petzold was some weeks ago my friend ;) not today, I am sorry. that's what I am intending to do for my personal aims using powerbasic and sdk frame windows. I like the idea to shorten code and so I was starting with cWindows and I am on the best way to fulfil my task. I am learning with powerbasic al lot of things and special gdiplus include statements, but sometimes I am wondering about speed optimation or "easy" handling with a long code example, I suggest it's not very smart to use a big bloat of code lines. it's better to use or build a DLL instead of ? this is a very important question for me. My knowledge about this one is less and  therefore  I am asking. My suggestions about this topic is, that a DLL for all processes and compiler actions are faster than usual include files (there might be for one application more than four, five include files). that's true ?

to be truly: I am not sure what it's the best way for creating a fast application without any speed relays and it's stabile and serious application for use !

hope you can answer about this topic or anybody else :)

good night, best regards, frank    

José Roca

Quote
there is any "disadvantage" of using sdk (I think there is factor * 3 in code lines for usual ddt frame code) for application speed ? it's a serious question to run an application. I think you know what I mean.

Pure SDK code produces smaller and faster executables. You use less lines of code with DDT, but the binary produced is somewhat bigger and slower because the compiler has to generate all the code you have been too lazy to write, and some more.

Quote
I suggest it's not very smart to use a big bloat of code lines. it's better to use or build a DLL instead of ? this is a very important question for me. My knowledge about this one is less and  therefore  I am asking. My suggestions about this topic is, that a DLL for all processes and compiler actions are faster than usual include files (there might be for one application more than four, five include files). that's true ?

Faster than what? If there are less lines of code, it will take less time to compile, but this doesn't mean that the program will run faster. Calling a function in a DLL is somewhat slower that if it is incorporated in the program.

But the differences are quite small, so what you use is mainly a matter of preferences.

Frank Brübach

#24
hello again :)

1) one more little question to my toolbar project. I will follow next time this task. Now I would like to add a "statusbar" with cWin. I have included this line

QuoteLOCAL hStatusbar AS DWORD
  hStatusbar = pWindow.AddStatusBar(hwnd, %IDSTATUSBAR, "", 0, 347, 535, 23, %WS_CHILD OR %WS_VISIBLE OR %CCS_TOP OR %TBSTYLE_FLAT)
  SendMessage hStatusbar, %WM_SETFONT, hFont, %TRUE

also thought it was necessary to include

Quote"msctls_statusbar32"
, but it doesn't work.

My new "statusbar" appears directly below or partly through my toolbar with button images (see picture below). I am sure something is missing. perhaps anybody can give a good hint where's my mistake.


2) quite other thing: one favour: one person (I don't know who was it) has changed my charma from "0" to "1" some weeks (month) ago, at that time I have done a lot of work here. After some weeks I think it was the same person changed backward my charma from "1" to "0". I don't understand such thing. I don't like this anonymous behaviour. in my eyes it's a disadvantage of this charma element at this website. this motivation elements for applauds or smiting people is only good if you can see from whom this "+" or "-" points were given. And I would like to know who is the person who did it in my case.
-> Would be better to install a "charma modul" with input for changing charma (who for what person and the reason why). such charma modul exists ! ;)

thanks, frank

José Roca


Use:


hStatusbar = pWindow.AddStatusBar(hwnd, %IDSTATUSBAR, "", 0, 347, 535, 23, %WS_CHILD OR %WS_VISIBLE OR %WS_CLIPCHILDREN OR %WS_CLIPSIBLINGS OR %CCS_BOTTOM OR %SBARS_SIZEGRIP)


and don't mix styles of other controls: %TBSTYLE_FLAT is for toolbars.

Quote
Would be better to install a "charma modul" with input for changing charma (who for what person and the reason why). such charma modul exists !

I know, but I don't like to install mods. They can became a nightmare when you update the forum to a new version.

Frank Brübach

#26
thanks jose for fast reply. my example works correctly with "statusbar" below placed where it should be. You are right: I've copied some styles from Toolbar control, didn't check that. my mistake.

QuoteI know, but I don't like to install mods. They can became a nightmare when you update the forum to a new version.

that's new for me. good to know that's a technical problem and probably sysiphos work. but I think it would be better to install such module (my personal opinion). I like to act with each nice person around me (private like professional) in a very fair and heartly way. so I am wondering why it's here anonymous to applaude or smite persons for their engagement. it's ok, I can't change that. today I can live with humour about this little red laughing evil thing ;)

servus, best regards, frank

Jürgen Huhn

Servus Frank!

At this point i have to say:

I like to read all your post`s very much and even your Strain to go a fair and heartly way.

That`s making the World a bit nicer! Thank you!

All my Best,

Jürgen
  ;)
.¸.•'´¯)¸.•'´¯)¸.•'´¯)¸.•'´¯)
¤ª"˜¨¨¯¯¨¨˜"ª¤....¤ ª"˜¨