String Table?  
Author Message
kineticAnimation





PostPosted: Visual C++ General, String Table? Top

Hello,
I have created an empty project, and managed to write some code that will create an empty window...

When I was experimenting, I thought that keeping ALL the text within the program in a string table (as a resource)... Would that be good Is that too inefficient

Anyways this this the code for the window:
=========code==============
#include <afxwin.h>

class MFC_Tutorial_Window :public CFrameWnd
{
public:
MFC_Tutorial_Window()
{
Create(NULL,_T("Test Window"));
}

};

class MyApp :public CWinApp
{
MFC_Tutorial_Window *wnd;
public:
BOOL InitInstance()
{
wnd = new MFC_Tutorial_Window();
m_pMainWnd = wnd;
m_pMainWnd->ShowWindow(SW_SHOW);
return TRUE;
}
};

MyApp theApp
;


=========code==============

And in the string table, this is the value of the string:
ID: IDS_WindowTitle
Value: 101
Caption: TestingWindow

Now, I'm thinking I have to edit this line:
Create(NULL,_T("Test Window"));
and replace _T("Test Window") with some code...
How do I call up the resource string and use that for the windows caption

Thank You!
Keehun Nam


Visual C++6  
 
 
kineticAnimation





PostPosted: Visual C++ General, String Table? Top

I was wondering if I use this function:

::StringFromIID()

But I don't know what the put as the values...
Can you guys help me out

Thanks!
Keehun

 
 
kineticAnimation





PostPosted: Visual C++ General, String Table? Top

Hmmm
I used this:

CString title;
title.LoadStringW(101);
Create(NULL,title);

 
 
Simple Samples





PostPosted: Visual C++ General, String Table? Top

In addition to:

CString title;
title.LoadStringW(101);

The following also works:

CString title((LPCSTR)101);

Except that won't create a Unicode string in a non-Unicode program; I assume that's not a problem.



 
 
Simple Samples





PostPosted: Visual C++ General, String Table? Top

 
Hello,
=========code==============

And in the string table, this is the value of the string:
ID: IDS_WindowTitle
Value: 101
Caption: TestingWindow

Now, I'm thinking I have to edit this line:
Create(NULL,_T("Test Window"));
and replace _T("Test Window") with some code...
How do I call up the resource string and use that for the windows caption

I think you revised your original question to include the additional comments above. If this was in your original question, then I did not see it (my fault). Whether it was there originally or not, I wasted a little time writing a reply that was not relevant; I have now deleted my irrelevant comments. If the clarification did not exist in the original question, then it sure would have helped to have had it originally.

As for your code, it seems to be an old MFC sample. You should find a more recent book/tutorial about MFC. MFC programs, especially for beginners, should be started by using the application generator available from "File | New".

If you use the application generator to create the starter application, then MFC generates code to get the main window's caption from the resources.