I'm new to Visual Studio & trying to build an application in it for the first time. The code compiles. I used to get the error load from the debugger as a result of not downloading the corresponding .pdb files. After changing a setting in the debugger options, all the the required files were downloaded from Microsoft servers, except the ones for guard32.dll & guard64.dll. I looked it up and found that they belong to Comodo Internet Security. My problem is that I don't know how to configure the debugger to ignore them. I tried adding it to the exclusion list in the debugger symbol settings and the error: Cannot find or open the PDB file just turned into another problem. Either way the program doesnt run. I really need some help here.

'TestWindow.exe' (Win32): Loaded 'C:\Users\James\Documents\Visual Studio 2012\Projects\TestWindow\Release\TestWindow.exe'. Symbols loaded.
'TestWindow.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Symbols loaded.
'TestWindow.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Symbols loaded.
'TestWindow.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Symbols loaded.
'TestWindow.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Symbols loaded.
'TestWindow.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr110.dll'. Symbols loaded.
'TestWindow.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Symbols loaded.
'TestWindow.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Symbols loaded.
'TestWindow.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Symbols loaded.
'TestWindow.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Symbols loaded.
'TestWindow.exe' (Win32): Loaded 'C:\Windows\SysWOW64\guard32.dll'. Loading disabled by Include/Exclude setting.
'TestWindow.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Symbols loaded.
'TestWindow.exe' (Win32): Loaded 'C:\Windows\SysWOW64\version.dll'. Symbols loaded.
'TestWindow.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Symbols loaded.
'TestWindow.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Symbols loaded.
'TestWindow.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Symbols loaded.
'TestWindow.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Symbols loaded.
'TestWindow.exe' (Win32): Loaded 'C:\Windows\SysWOW64\bcryptprimitives.dll'. Symbols loaded.
'TestWindow.exe' (Win32): Loaded 'C:\Windows\SysWOW64\fltLib.dll'. Symbols loaded.
'TestWindow.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntmarta.dll'. Symbols loaded.
'TestWindow.exe' (Win32): Loaded 'C:\Windows\SysWOW64\uxtheme.dll'. Symbols loaded.
The program '[604] TestWindow.exe' has exited with code -1 (0xffffffff).

Are you sure it doesn't run? That output seems to indicate that it did run, and it finished with a return value of -1.

What it seemed happened to me being a VS noob was that it started and then closed whenever it didn't successfully load the .pdb file. I don't know if this is logical, otherwise I screwed up in the code.

main.h

#include <Windows.h>

typedef HCURSOR cursorH;
typedef LPCSTR stringLpc;
typedef LPCWSTR stringLpcw;
typedef HBRUSH brushH;
typedef LONG wLong;
typedef HWND__ windowHandle;
typedef DWORD dbWord;
typedef HINSTANCE appInstance;
typedef BOOL wbool;
typedef ATOM atomw;
typedef WPARAM WPrm;
typedef WPARAM Lprm;
typedef UINT unsInt;

 LRESULT CALLBACK recieveEvent (HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);

class eventHandler { //completely static, similar to a namespace

public:
    typedef MSG eventMessage;
    inline static bool currentMessageisQuit ();
    inline static bool currentMSGisnotQuit ();
    inline static void captureEvent ();
    inline static eventMessage* currentMessage();
    inline static int eventParam ();
private:
    eventHandler ();
    static eventMessage current;

};

class WindowMSX : WNDCLASSEX {

public:
    inline WindowMSX ();
    inline WindowMSX (unsInt stylep, appInstance instance, cursorH cursor, brushH brush, stringLpcw name) ;
    inline windowHandle *canCreateHandle(const stringLpcw &title, const appInstance&);
    inline windowHandle *handle();
    inline void adjustWindow (wLong x, wLong y, wLong width, wLong height, bool usemenu, dbWord dwStyle);
    inline atomw isRegisterableWith(wLong x, wLong y, wLong width, wLong height, bool usemenu, dbWord dwStyle);
    inline atomw canBeRegistered ();
    inline wbool show(int cmdshow);

private:
    windowHandle *tothis;
    wLong rectsize[4];
    dbWord dwstyle;
};


WindowMSX::WindowMSX() {}

WindowMSX::WindowMSX (unsInt stylep, appInstance instance, cursorH cursor, brushH brush, stringLpcw name)
{

    cbSize = sizeof (WindowMSX);
    style = stylep;
    hbrBackground = brush;
    lpszClassName = name;
    lpszMenuName = NULL;
    hInstance = instance;
    hCursor = cursor;

}

void WindowMSX::adjustWindow (wLong x, wLong y, wLong width, wLong height, bool usemenu, dbWord dwStyle)
{
    rectsize [0] = x;
    rectsize [1] = y;
    rectsize [2] = width;
    rectsize [3] = height;
    dwstyle = dwStyle;

    RECT rc = {x, y, width, height};

    AdjustWindowRect (&rc, dwStyle, usemenu);
}

atomw WindowMSX::canBeRegistered()
{
    return RegisterClassEx (this);
}

windowHandle *WindowMSX::canCreateHandle (const stringLpcw &title, const appInstance&inst)
{
    tothis = CreateWindowA (lpszClassName, title, dwstyle, rectsize [0], rectsize [1], rectsize [2], rectsize [3], tothis, NULL, inst, NULL);
    return tothis;
}

windowHandle *WindowMSX::handle ()
{
    return tothis;
}

atomw WindowMSX::isRegisterableWith(wLong x, wLong y, wLong width, wLong height, bool usemenu, dbWord dwStyle)
{
    atomw r = canBeRegistered();
    adjustWindow(x, y, width, height, usemenu, dwStyle);
    return r;
}

wbool WindowMSX::show(int cmdshow)
{
    return ShowWindow (tothis, cmdshow);
}



bool eventHandler::currentMessageisQuit()
{
    return current.message == WM_QUIT;
}

bool eventHandler::currentMSGisnotQuit()
{
    return !currentMessageisQuit();
}

void eventHandler::captureEvent()
{
    if(PeekMessage (&current, 0, 0, 0, PM_REMOVE))
    {
        TranslateMessage(&current);
        DispatchMessage (&current);
    }
}

int eventHandler::eventParam()
{
    return static_cast <int> (current.wParam);
}

eventHandler::eventMessage *eventHandler::currentMessage()
{
    return &current;
}

main.cpp

#include "main.h"

eventHandler::eventMessage eventHandler::current = { 0 };

int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE prevInstance, LPWSTR cmdLine, int cmdShow) {

    _Unreferenced_parameter_ (prevInstance);
    _Unreferenced_parameter_ (cmdLine);

    WindowMSX window (
                CS_HREDRAW | CS_VREDRAW,
                hInstance,
                LoadCursor (NULL,    IDC_ARROW),
                (HBRUSH) (COLOR_WINDOW + 1),
                "DX11 window class"
                );

    if(! (/*the follow isnot true*/
      (window.isRegisterableWith(0, 0, 640, 480, false, WS_OVERLAPPEDWINDOW))
             &&
            (window.canCreateHandle ("test  window", hInstance))
            )) {
        return -1;
    }

    window.show (cmdShow);

    while (eventHandler::currentMSGisnotQuit()) {
        eventHandler::captureEvent();

        //some stuff...

    }

    return eventHandler::eventParam();

}


LRESULT CALLBACK recieveEvent(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{

    PAINTSTRUCT paintstrct;
    HDC hDc;

    switch (message) {

    case WM_PAINT:
        hDc = BeginPaint (hwnd, &paintstrct);
        EndPaint(hwnd, &paintstrct);
        break;
    case WM_DESTROY:
        PostQuitMessage(0); 
        break;

    default:
        return DefWindowProc (hwnd, message, wparam, lparam); //handles events with default behavior
    }

    return 0;
}

I see that your code will return -1 under some conditions, on line 23 above. Given that your program does return -1, how do you know that this isn't what's happening?

The exit code could be related to one of the function calls under certain conditions, which means I should've put function specific output to be sure, but I'm unaware of why any of those would be the case. Now I'm being stalled by a new error. The compiler is whining about the difference between LPCWSTR and LPCSTR. because I'm new to Visual C++, I'm unclear on how I'd fix this. Niether can I assign a c style string to LPCWSTR. So before I continue I have to fix those issues.

The compiler is whining about the difference between LPCWSTR and LPCSTR. because I'm new to Visual C++, I'm unclear on how I'd fix this.

That's nothing to do with Visual Studio or Visual C++. VS is just a tool; likewise Visual C++. You're using the Win32 API which is really not a recommended place to start graphical programming unless you really, really have to. You might find it better starting with one of the many graphical toolkits available.

While I remember, not being able to find a pdb file should not impede program running at all (and thus far, it looks like it didn't).

I think I have to use Visual C++ and the Win32 API for DirectX. I was a few steps into SDL & OpenGL, then with GLFW with OpenGL in Qt for the fact that they're supported on Mac and Linux etc... Then I decided to try DirectX for its features as well as the better performance it delivers on the platforms that support it. Currently, I'm just trying to get pass these problems I'm encountering, which atm, I'm trying to verify is non-related to .pdb files, which I can only do after figuring out what to do concerning my issues with the LPCWSTR and LPCSTR string types which recently began occurring for an unknown reason

I found the problem which wasn't related to .pdb files. It was that the window handle wasnt being created due to entering a string which differed from the one assigned to the lpszClassName string property into the CreateWindowA function. It runs fine now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.