News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

DrawThemeText to draw text but what is the api to retrieve the text?

Started by 2B||!2B, April 18, 2018, 02:47:27 PM

Previous topic - Next topic

2B||!2B

Hello,

So i basically use the DrawThemeText API to draw a text over a progress bar, now what is the API to retrieve the text drawn there?
I do not want to store extra structure inside the lParam member of the listview sub item. And because of that i need to just get the current text over the progress bar and redraw it in case a user hover the mouse over the progress bar for example it disappears because it needs to be redrawn again. Any ideas?

jj2007

If it's a progressbar, you'll be interested to see the last item, right? So just assign the last item to a dynamic string.

Btw, as a rule, without seeing (complete) code it's difficult to help you.

2B||!2B

Quote from: jj2007 on April 18, 2018, 03:45:54 PM
If it's a progressbar, you'll be interested to see the last item, right? So just assign the last item to a dynamic string.

Btw, as a rule, without seeing (complete) code it's difficult to help you.

But what if there are lots of items in the listview? will my program consume lots of memory?
I thought of using some kind of variables or just local buffer to get the last text assigned inside the progress bar then re asign it again on the redraw stage. (Kind of like if nothing happened)
About the code its a part of big application so i am not sure how i am going to share all of that just for a small piece of code.

jj2007

Even if you have lots of items in your listview, you need some mechanism to identify and/or load them: a text array, for example. How do you get the item text when the listview wants to draw it? Re memory: a Recall array needs the memory corresponding to the file size. Unless you have tens of Millions of listview items, that memory is negligible.

Besides, there is no API to retrieve the text. DrawThemeText uses a DC, not a control that you could ask to give you info on its internals.

2B||!2B

Quote from: jj2007 on April 18, 2018, 05:05:53 PM
Even if you have lots of items in your listview, you need some mechanism to identify and/or load them: a text array, for example. How do you get the item text when the listview wants to draw it? Re memory: a Recall array needs the memory corresponding to the file size. Unless you have tens of Millions of listview items, that memory is negligible.

Besides, there is no API to retrieve the text. DrawThemeText uses a DC, not a control that you could ask to give you info on its internals.

Hi jj

Actually the drawing process does not include text. It is only the progress bar which a request about redraw notifications has been made.
      

;WM_NOTIFY message
MOV EDI,lParam
MOV ECX, (NMHDR ptr[EDI]).idFrom
MOV EDX, (NMHDR ptr[EDI]).code

.if ECX == FILE_MANAGER_FILE_TRANSFER_LV_ID && EDX == NM_CUSTOMDRAW
MOV EDX,lParam ;NMLVCustomDRAW



.if [EDX].NMLVCUSTOMDRAW.nmcd.dwDrawStage == CDDS_ITEMPOSTPAINT OR  CDDS_SUBITEM
MOV EAX,[EDX].NMLVCUSTOMDRAW.iSubItem

.if EAX == FILE_MANAGER_LV_TRANSFER_PROGRESS
;Draw progress bar code is here...
invoke SetWindowLong,hWnd,DWLP_MSGRESULT,CDRF_SKIPDEFAULT
MOV EAX,TRUE
RET


.endif
.endif

.endif
invoke SetWindowLong,hWnd,DWLP_MSGRESULT,CDRF_NOTIFYPOSTPAINT OR CDRF_NOTIFYSUBITEMDRAW OR CDRF_NOTIFYITEMDRAW
MOV EAX,TRUE
RET

            
            

Anyway i solved it by using lParam item's specific data and made the DWORD into low word and high word, basically the high word contains the API error code (CreateFile/WriteFile) etc. The low word will hold GetLastError code. This way i can differentiate what to write inside the progress bar using DrawThemeText API.
Of course to force a redraw on the progress bar (to update the status etc) LVM_REDRAWITEMS message has to be sent.

About DrawText/DrawThemeText api's yes that's what i thought too.

Thanks.