Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Help Needed With Subclassing (Read 2678 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Help Needed With Subclassing

i want to try and add a lil bit of somthing to the WM_PAINT, ie, i wanna overwrite the standard win32 ghey gray windows.. with somthing a lil more nice looking, but with what i have at the min... it just locks the window up...
Code: [Select]
#include "../SDK/foobar2000.h"

LRESULT CALLBACK nWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
HWND foowind;
WNDPROC oldProcAddr;

class startup_main : public initquit
{
public:
    virtual void on_init();
    virtual void on_quit();
};

void startup_main::on_init() {
    foowind = FindWindow("FOOBAR2000_CLASS",NULL);
    oldProcAddr = (WNDPROC)SetWindowLong(foowind,GWL_WNDPROC,(long)nWndProc);
    InvalidateRect(foowind, NULL, TRUE);
}

void startup_main::on_quit() {
    SetWindowLong(foowind,GWL_WNDPROC,(long)oldProcAddr);
}

LRESULT CALLBACK nWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
    switch(uMsg) {
 case WM_PAINT: {
     HDC hdc;
     hdc = GetDCEx(hwnd, (HRGN)wParam, DCX_WINDOW|DCX_INTERSECTRGN);
     //paint code will end up here
     ReleaseDC(hwnd, hdc);
     CallWindowProc(oldProcAddr,hwnd,uMsg,wParam,lParam);
 }
 break;
 default:
     CallWindowProc(oldProcAddr,hwnd,uMsg,wParam,lParam);
 break;
    }
    return 1;
}

static service_factory_single_t<initquit,startup_main> foo;

DECLARE_COMPONENT_VERSION("Test","0.0",0)

can anyone see were im going wrong?

Help Needed With Subclassing

Reply #1
Subclassing is a simple way to get you banned from here for violation of forum rule #11, just like with X-Fixer, and get all your components into the banlist. "Components" that operate outside legal APIs and blow up when eg. loaded with different UI are not welcome here. If you want to change appearance of foobar2000, please write your own UI instead.
Microsoft Windows: We can't script here, this is bat country.