mIRC Home    About    Download    Register    News    Help

Print Thread
Page 2 of 2 1 2
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
I copied the example listed above pretty much verbatim into a new VS2010 project and then fixed any missing references / compiler errors (using Unicode):

Code:
#include <windows.h>

int createWindow(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)
{
    WNDCLASSEX wc;
    HWND hwnd;
    TCHAR className[] = L"MyWindow";
    HINSTANCE hInstance = GetModuleHandle(0);

    //Step 1: Registering the Window Class
    wc.cbSize        = sizeof(WNDCLASSEX);
    wc.style         = 0;
    wc.lpfnWndProc   = DefWindowProc;
    wc.cbClsExtra    = 0;
    wc.cbWndExtra    = 0;
    wc.hInstance     = hInstance;
    wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
    wc.lpszMenuName  = NULL;
    wc.lpszClassName = className;
    wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);

    if(!RegisterClassEx(&wc))
    {
        MessageBox(NULL, L"Window Registration Failed!", L"Error!",
            MB_ICONEXCLAMATION | MB_OK);
        return 0;
    }

    // Step 2: Creating the Window
    hwnd = CreateWindowEx(
        WS_EX_CLIENTEDGE,
        className,
        L"The title of my window",
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, CW_USEDEFAULT, 240, 120,
        NULL, NULL, hInstance, NULL);

    if(hwnd == NULL)
    {
        MessageBox(NULL, L"Window Creation Failed!", L"Error!",
            MB_ICONEXCLAMATION | MB_OK);
        return 0;
    }

    ShowWindow(hwnd, 1);
    UpdateWindow(hwnd);
    return 1;
}


The above works perfectly for me.

Note that you can only run the command once. The second time will fail because the RegisterClassEx function will fail, since you've already registered that window class. Ideally the registration of window classes should be done in the dll initialization, not for each /dll call, but this is just a proof of concept.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Jan 2011
Posts: 11
D
Pikka bird
OP Offline
Pikka bird
D
Joined: Jan 2011
Posts: 11
More mIRC crashes for me. I'm giving up on this. Sorry for the noise.

Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
What version of mIRC are you running? What version of windows?


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Jan 2011
Posts: 11
D
Pikka bird
OP Offline
Pikka bird
D
Joined: Jan 2011
Posts: 11
Windows 7 (64-bit) and the latest version of mIRC (7.19). I have to say that since I started working on this (from before I created this thread here -- literally a year ago) I used several versions of Windows, mIRC, and different compilers, all to no avail. Tried this with Windows XP, Windows Vista, and Windows 7 (32-bit and 64-bit). As far as compilers are concerned I used Visual Studio, Bloodshed Dev-C++ (which relies on MinGW I believe, and which is what I'm currently using), and even Cygwin. I've tried literally tens of examples/tutorials and setting variations (with unicode, without unicode, different frameworks and build options for each compiler (e.g. standard Win32 DLL, MFC DLL, etc), etc). I never once got it to work. Would you mind uploading your DLL somewhere so I can test it with my mIRC? If it causes the same problem then it must be my environment (although, like I said before, I've tried this on several different setups, i.e. different software settings but also different physical computers, e.g. my laptop, my desktop, from within a virtual machine, etc).

Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Sure. Source and dll here. The dll is in the Debug\ directory.



- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Nov 2011
Posts: 15
J
Pikka bird
Offline
Pikka bird
J
Joined: Nov 2011
Posts: 15
deadbeef, did you solve your problem? I need to show a MessageBox from a DLL but it doesn't work well for me.

Can you post your source code?

Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
The source was already posted. But showing a MessageBox is considerably easier than opening a window, it's nothing more than MessageBox(NULL, "Hello world", "Title", MB_OK);

I've added many a messagebox into mIRC dlls, and I know they absolutely work fine.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Nov 2011
Posts: 15
J
Pikka bird
Offline
Pikka bird
J
Joined: Nov 2011
Posts: 15
Thanks for your reply argv0.

Reading this post make me thought that there are more people with my same problem, but the DLL I was tring to create was for XChat (another IRC client). I successfully compiled the DLL without errors, but in runtime, the MessageBox didn't work well, here it is what happened with it:

http://forum.xchat.org/viewtopic.php?t=5661

Does somebody know how to solve this?

Last edited by jomalin; 29/11/11 10:54 PM.
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
You do realize that DLLs for mIRC are probably incompatible with XChat, right?


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Nov 2011
Posts: 15
J
Pikka bird
Offline
Pikka bird
J
Joined: Nov 2011
Posts: 15
I know...

I'm only asking if somebody know how to do that, independently if it is for mIRC or XChat. I believed showing a MessagaBox from a DLL also in mIRC gave the same problem...

So, does somebody know why this happen in XChat?

Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Again, this is a forum for mIRC. If you have questions about XChat you should ask users of XChat. I showed you how to display a messagebox. The method works in mIRC. If it doesn't work in XChat it's something you have to deal with in XChat's support forums. Frankly, we don't really care why it wouldn't work in that client. As a sidenote, looking at the very forum topic you posted on XChat, it seems they already explained to you why it doesn't work (you need to use threads). Perhaps you should ask them to explain this to you, since it seems you either didn't read the answer, or didn't understand it.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Page 2 of 2 1 2

Link Copied to Clipboard