News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Windows XP themes

Started by lamer, April 17, 2006, 10:40:48 AM

Previous topic - Next topic

lamer

Hi all!
Has anybody ever worked with XP themes? I mean with uxtheme.dll? I'm just trying to, but even the first call to OpenThemeData function returns 0. I have examples in C++ and VB - everything is working. Here are my files:
Resource:
#define IDD_DLG_XP 1000
#define IDC_BTN_XP 1001

IDD_DLG_XP DIALOGEX 6,6,194,102
CAPTION "xpTest"
FONT 8,"MS Sans Serif",400,0
STYLE 0x10CF0000
EXSTYLE 0x00000000
BEGIN
  CONTROL "Click",IDC_BTN_XP,"Button",0x50010000,58,35,76,20,0x00000000
END


Code:
.486
.model flat,stdcall
option casemap:none

include windows.inc
include user32.inc
include kernel32.inc
include comctl32.inc

includelib user32.lib
includelib kernel32.lib
includelib comctl32.lib

DlgProc                          PROTO :HWND,:UINT,:WPARAM,:LPARAM

;xpTest.dlg
IDD_DLG_XP equ 1000
IDC_BTN_XP equ 1001


.data?
hInstance HINSTANCE ?
m_ThemesLib DWORD ?

.data
szXpThemeLib    db    "uxtheme.dll",0
szIsThemeActive    db    "IsThemeActive",0
szOpenThemeData    db    "OpenThemeData",0
szCloseThemeData    db    "CloseThemeData",0
szButton    db    "button",0
szToolbar    db    "toolbar",0
icc    INITCOMMONCONTROLSEX    <sizeof INITCOMMONCONTROLSEX,ICC_USEREX_CLASSES>

.code
start:
invoke InitCommonControlsEx,addr icc
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke LoadLibrary,addr szXpThemeLib
mov m_ThemesLib,eax

invoke DialogBoxParam,hInstance,IDD_DLG_XP,NULL,addr DlgProc,NULL
.if m_ThemesLib
invoke FreeLibrary,m_ThemesLib
.endif
invoke ExitProcess,0

DlgProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM

LOCAL hProc :DWORD
LOCAL hTheme :DWORD

.if uMsg==WM_CLOSE
invoke EndDialog,hWnd,NULL
.elseif uMsg==WM_COMMAND
mov eax,wParam
and eax,0FFFFh
.if eax==IDC_BTN_XP
.if m_ThemesLib
invoke GetProcAddress,m_ThemesLib,addr szOpenThemeData
.if eax
mov hProc,eax
push offset szButton
push hWnd
call hProc    ;THIS RETURNS 0!!!!!
.if eax
mov hTheme,eax
invoke GetProcAddress,m_ThemesLib,addr szCloseThemeData
push hTheme
call eax
.endif
.endif
.endif
.else
mov eax,FALSE
ret
.endif
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret

DlgProc endp
end start

May be somebody has faced with a question yet?..
Thank you.


ramguru

Lamer what are you doing? ..pretending LAMER :) ?
1. You can find uxtheme.lib in PSDK (why make things difficult)
2. You can make uxtheme.inc with "l2inc uxtheme.lib"
3. You must write a unicode string:
f.e. |but  db "B",0,"u",0,"t",0,"t",0,"o",0,"n",0,0,0|

[attachment deleted by admin]

lamer

ramguru - thanks! :U
Quote from: ramguru on April 17, 2006, 12:33:58 PM
Lamer what are you doing? ..pretending LAMER :) ?
btw - it's very good position. Nobody can upbrain a lamer for his lamerism  :bg
QuoteYou must write a unicode string:
That was the point. Thanks again. I've posted the question in 5 forums - this is the first and, I think, the only answer.
P.S.
imho, it's not safe to use .inc and .lib in this case - what if program will run on W2K or Me?

ramguru

Quote from: lamer on April 17, 2006, 02:40:17 PM
P.S.
imho, it's not safe to use .inc and .lib in this case - what if program will run on W2K or Me?
IMO it's safe, cause application will search for actual lib (.dll) in app dir anyway. (sqlite3 works that way..)

lamer

So you need to distribute the library with application?
Anyway, I have rejected the idea to use XP themes - I've seen application which draw "XP theme"-like controls even if Windows is set to use classic interface. They use current color scheme and draw nice controls. The point was to find the second color for gradient, based on currently selected color scheme - and I think I have found it - just left shift by 1 bit for button face color, when the first gradient color is button highlight.
Thank you.

P1

Quote from: lamer on April 17, 2006, 06:24:22 PMand I think I have found it - just left shift by 1 bit for button face color, when the first gradient color is button highlight.
You can always roll your own smokes lamer.  But then it gets folks a thinking what you are a smokin'.   ó¿ò

Regards,  P1  :8)


lamer

P1,
My english is enough for understanding help files or asking a check in restaurant, not more. :eek
Would you explain yourself a bit, please?

P1

Quote from: P1 on April 17, 2006, 07:47:49 PMYou can always roll your own smokes lamer.
Back when mass produced cigarettes were so much cheaper ( no taxes to speak of ) than buying the papers, getting the shredded tobacco and rolling the cigarette yourself.  The play on words to the effect of, we offered you a cigarette ( mass produced/easy/cheap solution ), and you decided to go through all the trouble of rolling a cigarette ( your own solution to your problem ).

Quote from: P1 on April 17, 2006, 07:47:49 PMBut then it gets folks a thinking what you are a smokin'.   ó¿ò
But with the culture of drugs in the USA, most of the people rolling cigarettes, were not using tobacco but weed.  Was a allusion to the fact, you had other goals not discussed openly for the code request.

It was high placed humor, but missed the mark, because I thought you had a better understanding of English and American culture.

I'm sorry it confused you.  And will do better in the future.

Regards,  P1  :8)

lamer

QuoteWas a allusion to the fact, you had other goals not discussed openly for the code request.
At the moment this was exactly the goal - I intended to use XP themes. And then between the posts I decided to do it without them.
BTW, what about adding new subforum - something like "English for dummies'?  :bg

hutch--

 :bg

The problem with a subforum titled "English for Dummies" is that most of the questions would be from people who are supposed to be native English speakers.

Now when it comes to "rolling your own", I don't because the tobacco you can get for rollies is not worth smokin'. The up side of smoking roll your own is they take a lot longer to roll so you end up smoking less although I have seen some of the old fellas who can roll a cigarette with one hand while doing something else with the other.

I never saw anyone do it with a joint as they were usually too far out of it to succeed.  :P

Lamer, what is your native language ?
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

lamer

Russian... Although I left 15 years ago.

evlncrn8

Quote from: hutch-- on April 17, 2006, 10:30:38 PM
:bg
Now when it comes to "rolling your own", I don't because the tobacco you can get for rollies is not worth smokin'.

yeh i dont put tobacco in my own either.. its still organic though :P

Mark Jones

Quote from: evlncrn8 on April 18, 2006, 02:15:04 PM
yeh i dont put tobacco in my own either.. its still organic though :P

Once I rolled a whole 6oz. can of tobacco into a giant paper and smoked that over the course of two days... :green
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Light-I

Quote from: ramguru on April 17, 2006, 12:33:58 PM3. You must write a unicode string:
f.e. |but  db "B",0,"u",0,"t",0,"t",0,"o",0,"n",0,0,0|
Other, simplest way :but  dw "Button", 0

ramguru

This probably won't work in masm  :bg , in poasm it's OK. I've written that way only just for clarity (to show how bytes are organized in unicode-16). No doubt there are many good macros for that purpose.