Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

GetDlgItemText. Write to static class member. Unresolved External.

$
0
0
class newtonsmethod
{
public:
	newtonsmethod();
	~newtonsmethod();
	void RunMessageLoop();
	HRESULT Initialize();
	HRESULT CreateDeviceIndependentResources();
	static LRESULT CALLBACK WindowProc(_In_  HWND hwnd, _In_  UINT uMsg, _In_  WPARAM wParam, _In_  LPARAM lParam);
	HRESULT OnRender();
	HRESULT CreateDeviceResources();
	void OnResize(UINT width,UINT height);
	void DiscardDeviceResources();
	static BOOL CALLBACK GraphItemProcedure(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam);
	ID2D1Factory* m_pDirect2dFactory;
	ID2D1HwndRenderTarget* m_pRenderTarget;
	ID2D1SolidColorBrush* m_pLightSlateGrayBrush;
	ID2D1SolidColorBrush* m_pCornflowerBlueBrush;
	static WCHAR szEquation[80];
	HINSTANCE m_hInstance;
	HWND m_hwnd;
	MSG msg;
};

BOOL CALLBACK newtonsmethod::GraphItemProcedure(HWND hwndDlg,
	UINT message,
	WPARAM wParam,
	LPARAM lParam)
{
	switch (message)
	{
	case WM_COMMAND:
		switch (LOWORD(wParam))
		{
		case IDOK:
			if (!GetDlgItemText(hwndDlg, IDC_EDIT1, szEquation, 80))
			{
				*szEquation = 0;
			}
				//*szEquation = 0;

			// Fall through. 
			//return TRUE;
		case IDCANCEL:
			EndDialog(hwndDlg, wParam);
			return TRUE;
		}
	}
	return FALSE;
}

When I try to build the application I get a warning and two errors:

Warning 1 warning C4715: 'WinMain' : not all control paths return a value c:\users\eric\documents\visual studio 2013\projects\newtonsmethod\newtonsmethod\main.cpp 18 1 newtonsmethod
Error 2 error LNK2001: unresolved external symbol "public: static wchar_t * newtonsmethod::szEquation" (?szEquation@newtonsmethod@@2PA_WA) C:\Users\Eric\documents\visual studio 2013\Projects\newtonsmethod\newtonsmethod\newtonsmethod.obj newtonsmethod
Error 3 error LNK1120: 1 unresolved externals C:\Users\Eric\documents\visual studio 2013\Projects\newtonsmethod\Debug\newtonsmethod.exe newtonsmethod

I tried making szEquation a global variable declared outside of WinMain however GraphItemProcedure was unable to find that szEquation exists in that configuration

Does anyone have any suggestions on how to get this working?

Thanks!

Additionally I tried specifying newtonsmethod::szEquation to access the buffer but it still leads to unresolved external.

Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>