The MASM Forum

General => The Campus => Topic started by: xandaz on February 28, 2021, 10:40:07 PM

Title: Having trouble with EM_GETIMECOLOR!!!
Post by: xandaz on February 28, 2021, 10:40:07 PM
    I'm building this multidocument interface editor and i'm having trouble with EM_GETIMECOLOR. When i load the Project EM_SETIMECOLOR does nothing only EM_SETCHARFORMAT is working. Does anyone have any idea of why this is happening?    mov [edi.COMPCOLOR.dwEffects],CFE_BOLD+CFE_ITALIC
    invoke SendMessage,[eax.MdiStruct.hEdit],EM_GETIMECOLOR,0,edi
    invoke SendMessage,[eax.MdiStruct.hEdit],EM_SETIMECOLOR,0,edi
    add edi,
Title: Re: Having trouble with EM_GETIMECOLOR!!!
Post by: xandaz on February 28, 2021, 11:07:28 PM
   The error on EM_SETIMECOLOR is 0x5 ACCESS DENIED. Thanks
Title: Re: Having trouble with EM_GETIMECOLOR!!!
Post by: jj2007 on February 28, 2021, 11:14:15 PM
Try PostMessage, sometimes it works.
Title: Re: Having trouble with EM_GETIMECOLOR!!!
Post by: hutch-- on February 28, 2021, 11:23:01 PM
The problem may be that the IME messages are only supported on Windows version for languages that require IME.
Title: Re: Having trouble with EM_GETIMECOLOR!!!
Post by: xandaz on March 01, 2021, 02:21:56 AM
   Thanks guys.... a lot.
Title: Re: Having trouble with EM_GETIMECOLOR!!!
Post by: xandaz on March 01, 2021, 04:14:52 AM
   So, the problem is how to get the current background color for the edit control. Since the isnt any EM_GETBKGNDCOLOR message i would like to know how you would deal with this since IME isn't avaiable. Thanks
Title: Re: Having trouble with EM_GETIMECOLOR!!!
Post by: xandaz on March 01, 2021, 05:38:35 AM
    hi....i recentlly found out that there is a CHARFORMAT2 Structure. Still not working butit seems that way to go. Thanks
Title: Re: Having trouble with EM_GETIMECOLOR!!!
Post by: xandaz on March 01, 2021, 06:35:22 AM
   Can't get the CHARFORMAT2 struct to work together with EM_SETCHARFORMAT. It's suppose to identify the type of struct through the cbSize member but it doesn't work. I'm disapointed.
Title: Re: Having trouble with EM_GETIMECOLOR!!!
Post by: jj2007 on March 01, 2021, 07:57:14 AM
Post code...
Title: Re: Having trouble with EM_GETIMECOLOR!!!
Post by: xandaz on March 01, 2021, 07:59:29 AM
code:    invoke RtlZeroMemory,edi,sizeof CHARFORMAT2W
    mov [edi.CHARFORMAT2.cbSize],sizeof CHARFORMAT2W
    mov [edi.CHARFORMAT2.dwMask],CFM_FACE+CFM_COLOR+CFM_BACKCOLOR+CFM_BOLD+CFM_ITALIC
    mov [edi.CHARFORMAT2.dwEffects],CFE_BOLD+CFE_ITALIC
    mov eax,LongVal
    invoke SendMessage,[eax.MdiStruct.hEdit],EM_GETCHARFORMAT,SCF_ALL,edi
    add edi,sizeof CHARFORMAT2
    mov [edi.CHARFORMAT2.cbSize],sizeof CHARFORMAT2W
    mov [edi.CHARFORMAT2.dwMask],CFM_FACE+CFM_COLOR+CFM_BACKCOLOR+CFM_BOLD+CFM_ITALIC
    mov eax,LongVal
    invoke SendMessage,[eax.MdiStruct.hEdit],EM_SETCHARFORMAT,SCF_ALL,edi
    add edi,sizeof CHARFORMAT2
Title: Re: Having trouble with EM_GETIMECOLOR!!!
Post by: jj2007 on March 01, 2021, 08:47:32 AM
The definition in the .data? section?
[eax.MdiStruct.hEdit] is a valid handle, for a RichEdit control?
GetLastError value?

CFM_FACE+CFM_COLOR+CFM_BACKCOLOR+CFM_BOLD+CFM_ITALIC

You should never use the + sign to compose flags!
Title: Re: Having trouble with EM_GETIMECOLOR!!!
Post by: xandaz on March 01, 2021, 08:56:20 AM
    Error value = 0 SUCCESS. The edi reigster points to the memory space of a project file where the CHARFORMAT struct is inserted. Doesnt return the Face name of the font.
Title: Re: Having trouble with EM_GETIMECOLOR!!!
Post by: jj2007 on March 01, 2021, 08:57:49 AM
Quote from: xandaz on March 01, 2021, 08:56:20 AMmemory space of a project file where the CHARFORMAT struct is inserted

I don't insist that you post the complete code, but my crystal ball is broken tonight, so could you please show us at least the few lines in the .data? section? Thanks.

Btw there are 52 matches for CHARFORMAT in the source code of RichMasm. They all work just fine.
Title: Re: Having trouble with EM_GETIMECOLOR!!!
Post by: HSE on March 01, 2021, 11:23:02 AM
Richedit have several versions. CHARFORMAT2 it's not available in older versions. I don't remember if you need superior to 3.0. There is no warning. You can store charformat2, but Richedit only read charformat, that is first part of structure.(background color is in last part)
Title: Re: Having trouble with EM_GETIMECOLOR!!!
Post by: jj2007 on March 01, 2021, 04:43:07 PM
Quote from: HSE on March 01, 2021, 11:23:02 AMCHARFORMAT2 it's not available in older versions.

That's true but it's difficult to find a sufficiently old version on a post-XP PC... I see that your crystal ball is not working, either  :tongue:
Title: Re: Having trouble with EM_GETIMECOLOR!!!
Post by: HSE on March 01, 2021, 08:54:14 PM
By default I use Richedit20   :biggrin:. No charformat2.
Title: Re: Having trouble with EM_GETIMECOLOR!!!
Post by: TouEnMasm on March 02, 2021, 01:20:50 AM

<>       ;------ATCHOUM---------
must be the covid !
Title: Re: Having trouble with EM_GETIMECOLOR!!!
Post by: TouEnMasm on March 02, 2021, 01:32:51 AM
To use properly the common contols structures, you need to know:
* The version of the windows system
* The version of richedit.
* ++++++++++++++
Title: Re: Having trouble with EM_GETIMECOLOR!!!
Post by: xandaz on March 07, 2021, 06:12:19 AM
   Sorry for the long reply. Your answers helped. I git over it. I have an issue tho. I have a button witha string and awnted to change the for to the general font used but the app. I send WM_SETFONT,hFont,TRUE but nothing happens. Any idea why. should i use BS_OWNERDRAW?
Title: Re: Having trouble with EM_GETIMECOLOR!!!
Post by: xandaz on March 07, 2021, 07:24:57 AM
QuoteYou should never use the + sign to compose flags!

Why this JJ? Isn't it the same as OR?
Title: Re: Having trouble with EM_GETIMECOLOR!!!
Post by: jj2007 on March 07, 2021, 08:04:12 AM
Quote from: xandaz on March 07, 2021, 07:24:57 AM
QuoteYou should never use the + sign to compose flags!

Why this JJ? Isn't it the same as OR?

Test it:
  mov eax, WS_OVERLAPPEDWINDOW+WS_THICKFRAME
  mov ebx, WS_OVERLAPPEDWINDOW or WS_THICKFRAME
Title: Re: Having trouble with EM_GETIMECOLOR!!!
Post by: TouEnMasm on March 07, 2021, 07:08:00 PM
+ isn't the same as or.
11 + 1 = 100b
11 or 1 = 11b
Title: Re: Having trouble with EM_GETIMECOLOR!!!
Post by: TouEnMasm on March 07, 2021, 07:58:58 PM
Most of the time,windows constants are defined as follow:
OneConst equ 1 SHL 0      ;1b
TwoConst equ 1 SHL 1      ;10b       and so on so you can define 32 or 64 constants it's enough most of the time

This made that you can use the signe + or OR with no different results.
OneConst + TwoConst = OneConst OR TwoConst

It's the case for the WS_OVERLAPPEDWINDOW+WS_THICKFRAME

Quote
   Local phrase[100h]:BYTE
   invoke sprintf,addr phrase,TXT("WS_OVERLAPPEDWINDOW+WS_THICKFRAME %x,WS_OVERLAPPEDWINDOW or WS_THICKFRAME %x"),\
               WS_OVERLAPPEDWINDOW+WS_THICKFRAME,WS_OVERLAPPEDWINDOW or WS_THICKFRAME
   invoke MessageBox,NULL,addr phrase,TXT("titre"),MB_OK

Result is the same CF0000h



Title: Re: Having trouble with EM_GETIMECOLOR!!!
Post by: hutch-- on March 07, 2021, 09:44:11 PM
xandaz,

Always use OR to combine styles, + works in some contexts but not all.
Title: Re: Having trouble with EM_GETIMECOLOR!!!
Post by: xandaz on March 08, 2021, 01:35:50 AM
   Thanks a lot guys. It's been helpful. Ty cu soon.