Link windows.h (WNDCLASSEX) code in VS2010 console application

I have a VS2010 Win32 console application. Within this console application I try to attach a window as child to another Win32 app. But I do not get the application linked (it compiles, just the linker issue AFAIK):

Error   1   error LNK2019: unresolved external symbol "long __stdcall viewproc(struct HWND__ *,unsigned int,unsigned int,long)" (?viewproc@@YGJPAUHWND__@@IIJ@Z) referenced in function "void __cdecl createFSXWindow(void)" (?createFSXWindow@@YAXXZ)  H:\Projects\VisualStudioNet2010\FSXTests\Menu Items\Menu Items\MenuItems.obj    Menu Items

I have added all libs from a Win32 Windows project under Linker/include:

kernel32.lib;user32.lib;gdi32.lib;winspool.lib; comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib; odbccp32.lib;%(AdditionalDependencies)

Remark: Just to clarify, I do NOT(!) try to attach the window to the console window, but another Win32 application, so it is not about "Make a win32 console app display a window"

The issue comes in once I add the window code such as:

#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include <strsafe.h>
....

// window
WNDCLASSEX wc;
wc.style = CS_HREDRAW | CS_VREDRAW ;
wc.lpfnWndProc = viewproc;

When I check the command line of the linker the only difference between my console app and an Win32 app is SUBSYSTEM:CONSOLE vs. SUBSYSTEM:WINDOWS

Any hints?

Answers


The linker error just tells you that you forgot to write the viewproc() function.

You declared it, the compiler is happy, but didn't implement it, the linker is unhappy. Or you wrote it but mistyped the definition. It is not a function that's implemented in one of the standard libraries, you have to provide it. The window procedure is what you use to give a window custom behavior.


Need Your Help

In angular-google-maps, what's the right way to bind to click events on a polygon

angularjs google-maps angular-google-maps

I'm trying to bind a function to a click event on a polygon in Google maps using angular-google-maps. Here's how I define the polygon:

Regular Expression to match all characters up to next match

javascript regex parsing

I'm parsing text that is many repetitions of a simple pattern. The text is in the format of a script for a play, like this: