Author Topic: GDI and richedit  (Read 778 times)

AW

  • Member
  • *****
  • Posts: 2048
  • Let's Make ASM Great Again!
Re: GDI and richedit
« Reply #15 on: May 26, 2019, 03:08:43 PM »
So, hwndButton is a local variable of function InitInstance.

jj2007

  • Member
  • *****
  • Posts: 9469
  • Assembler is fun ;-)
    • MasmBasic
Re: GDI and richedit
« Reply #16 on: May 26, 2019, 04:58:49 PM »
That code throws lots of errors, it seems somebody has to add the necessary includes etc.

TimoVJL

  • Member
  • ***
  • Posts: 300
Re: GDI and richedit
« Reply #17 on: May 26, 2019, 08:25:07 PM »
maybe GetDlgItem help, if you don't want to use a global button handles.
May the source be with you

daydreamer

  • Member
  • ****
  • Posts: 808
  • watch Chebyshev on the backside of the Moon
Re: GDI and richedit
« Reply #18 on: May 26, 2019, 10:11:34 PM »
So, hwndButton is a local variable of function InitInstance.
Thanks
So annoying with c++ overload
The second Hwndbutton 's is globals with same name,but not connected to buttons,not defined
Got it working changing text on B1
Any way to change warning level so it warns about overload?
Thanks timo
Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*
MM,XMM,YMM,ZMM registers,whats next?use nonenglish 29 letter alphabet,ÅMM,ÄMM,ÖMM registers?:D

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6341
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: GDI and richedit
« Reply #19 on: May 26, 2019, 10:28:06 PM »
Magnus,

I have read through this thread and I still don't know what you are trying to do. A button is just a simple UI component that does not have anything to do with Graphic Device Interface (GDI). It is also a control that you don't have much adjustment with, only text and size. A button press can be accessed as a message from either its handle which is a unique ID number OR its control number.

Now if you want to code a custom button which is not all that hard to do, you create a window using CreateWindowEx() then display whatever interface on it you want. It can be a bitmap or a rectangle where you generally set the text with an API like DrawText(). Let un know what you are try to get as an end result and we may be able to help you.

LATER : Here is the bare minimum for changing a button text while clicking on it.
« Last Edit: May 26, 2019, 11:58:52 PM by hutch-- »
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

daydreamer

  • Member
  • ****
  • Posts: 808
  • watch Chebyshev on the backside of the Moon
Re: GDI and richedit
« Reply #20 on: May 27, 2019, 12:49:42 AM »

LATER : Here is the bare minimum for changing a button text while clicking on it.
great thanks Steve :thumbsup: :eusa_clap:
now I can work on graphics with GUI version of question and with different answers to click buttons with,which I want to reuse for different answers/questions
a riddle for example
maybe an idea to have a variable called used in switch RIGHTANSWER that is set to the ID of the button with right answer
GDI is for draw some nice background and some person that asks the riddles



« Last Edit: May 27, 2019, 02:19:26 AM by daydreamer »
Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*
MM,XMM,YMM,ZMM registers,whats next?use nonenglish 29 letter alphabet,ÅMM,ÄMM,ÖMM registers?:D

daydreamer

  • Member
  • ****
  • Posts: 808
  • watch Chebyshev on the backside of the Moon
Re: GDI and richedit
« Reply #21 on: June 09, 2019, 03:17:41 AM »
testing time
facts from wikipedia
Please test,disabled call to tunnel drawing code
Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*
MM,XMM,YMM,ZMM registers,whats next?use nonenglish 29 letter alphabet,ÅMM,ÄMM,ÖMM registers?:D

jj2007

  • Member
  • *****
  • Posts: 9469
  • Assembler is fun ;-)
    • MasmBasic
Re: GDI and richedit
« Reply #22 on: June 09, 2019, 05:04:01 AM »
When resizing, it stops with a stack overrun.

daydreamer

  • Member
  • ****
  • Posts: 808
  • watch Chebyshev on the backside of the Moon
Re: GDI and richedit
« Reply #23 on: June 09, 2019, 08:43:16 PM »
When resizing, it stops with a stack overrun.
which OS?
dragging window edges?or minimize/maximize?
Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*
MM,XMM,YMM,ZMM registers,whats next?use nonenglish 29 letter alphabet,ÅMM,ÄMM,ÖMM registers?:D

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6341
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: GDI and richedit
« Reply #24 on: June 09, 2019, 10:01:55 PM »
Magnus,

Crashes on resize here. Win 10 64 Pro.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

daydreamer

  • Member
  • ****
  • Posts: 808
  • watch Chebyshev on the backside of the Moon
Re: GDI and richedit
« Reply #25 on: June 10, 2019, 12:17:07 AM »
I myself noted a less serious bug,maybe someone noticed there appear double answers of right answer on buttons,one is coded to be right answer and the other you get wrong answer because of lacking check for double answers

thanks for testing,Hutch,Jochen
I tested myself dragging and it works few pixels before I get exception handler shows up in debug and shows reference to updatewindow and where my GDI drawtext is,too many paint messages is stacked and calls too?
add some exception handling code?


Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*
MM,XMM,YMM,ZMM registers,whats next?use nonenglish 29 letter alphabet,ÅMM,ÄMM,ÖMM registers?:D

jj2007

  • Member
  • *****
  • Posts: 9469
  • Assembler is fun ;-)
    • MasmBasic
Re: GDI and richedit
« Reply #26 on: June 10, 2019, 07:43:38 AM »
which OS?
dragging window edges?or minimize/maximize?

dragging window edges on Win7-64

Tedd

  • Member
  • ***
  • Posts: 377
  • Procrastinor Extraordinaire
Re: GDI and richedit
« Reply #27 on: June 12, 2019, 10:37:52 PM »
It looks like you're creating GDI resources (pens, brushes) on every draw, but not cleaning them up again (DeleteObject), only to create them all over again on the next draw, and the next, and the next, and.. oh dear.
It's generally better to create them once at startup, then use them as needed, and delete them on exit.

Another issue is that you're from calling InvalidateRect in response to all WM_COMMAND messages, even ones you're not interested in. Only call InvalidateRect when there is something to be drawn.
For a silly example: note the current question, then click the About menu item -- the question changes.
Potato2

daydreamer

  • Member
  • ****
  • Posts: 808
  • watch Chebyshev on the backside of the Moon
Re: GDI and richedit
« Reply #28 on: June 13, 2019, 01:08:12 AM »
It looks like you're creating GDI resources (pens, brushes) on every draw, but not cleaning them up again (DeleteObject), only to create them all over again on the next draw, and the next, and the next, and.. oh dear.
It's generally better to create them once at startup, then use them as needed, and delete them on exit.

Another issue is that you're from calling InvalidateRect in response to all WM_COMMAND messages, even ones you're not interested in. Only call InvalidateRect when there is something to be drawn.
For a silly example: note the current question, then click the About menu item -- the question changes.
I gonna fix that with messages
thanks,maybe better to solve showing score and right wrong different,than to draw it
want to place drawing in a separate thread,so it doesnt make controls laggy

Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*
MM,XMM,YMM,ZMM registers,whats next?use nonenglish 29 letter alphabet,ÅMM,ÄMM,ÖMM registers?:D

Tedd

  • Member
  • ***
  • Posts: 377
  • Procrastinor Extraordinaire
Re: GDI and richedit
« Reply #29 on: June 13, 2019, 05:06:48 AM »
thanks,maybe better to solve showing score and right wrong different,than to draw it
want to place drawing in a separate thread,so it doesnt make controls laggy
There shouldn't be any problem with drawing, as long as you do it correctly :tongue:
I don't expect a separate thread will be necessary unless you're planning on doing lots of continuous drawing, i.e. animations.
Potato2