|
Does the project have to be an MFC project or can I include the MFC classes by including files?
I am using a console project to develop the classes because the code is simpler to test that way.
I have tried all the options within VS2003 for Run-time library but the code wouldn't compile in any case.
Also, I could not find stdafx.h, is it because it's not an MFC project?
Jon
|
|
|
|
|
jon_80 wrote: Does the project have to be an MFC project or can I include the MFC classes by including files?
it's far easier to do it from a project that was created to work with MFC than it is to add MFC after the fact. i'm not sure of all the steps, but you'll need to #include some stuff, set some #defines for the compiler, link the appropriate MFC libs, etc..
if you already have a non-MFC project, you might be better off with using std::string and std::vector:
#include < string>
#include < vector>
using namespace std;
...
vector < string > sentences;
sentences.push_back("this is a sentence");
sentences.push_back("this is another sentence");
...
string s = sentences[0];
etc.
Do the chickens have large talons?
|
|
|
|
|
|
Hi fellows
I`m trying to create a treeview in my app but I don`t have any sucess.
I`ve read the Microsoft article [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/treeview/treeview.asp[/url]
and I`ve tried to do something like that. The problem is that whem I create a node in a function that I created it returns NULL. I think that my code is right, so what`s going on??
Thanks for the support.
Below is my code?
I created my treeview like this:
<br />
treeViewHwnd = CreateWindowEx(WS_EX_LEFT, WC_TREEVIEW, "theTreeView", WS_CHILD|WS_VISIBLE|TVS_EDITLABELS|TVS_HASBUTTONS|TVS_HASLINES|TVS_LINESATROOT, 0, 0, 150, 600, hwnd, NULL, hCurrentInstance, NULL);<br />
treeViewHwnd is a global HWND.
In this part I want to put a node in the treeview
<br />
case WM_CHAR:<br />
{<br />
switch(wParam)<br />
{<br />
case 'a':<br />
{<br />
InitCommonControls();<br />
treeViewHwnd = GetDlgItem(hwnd, IDC_TREE1);<br />
OpenedWindows(GetForegroundWindow());<br />
for(int i = 0 ; i < sNameHwnds.size() ; i++)<br />
{ <br />
InsertNodeInTV(hwnd, sNameHwnds[i], 1);<br />
MessageBox(NULL, sNameHwnds[i].c_str(), "", MB_OK);<br />
break;<br />
}<br />
break;<br />
}<br />
.....<br />
And here I create the node:
<br />
#define IDC_TREE1 10<br />
HTREEITEM InsertNodeInTV(HWND tvHwnd, string sNodeName, int iLevel)<br />
{<br />
static HTREEITEM ParentItem, BeforeItem, RootItem;<br />
ParentItem = (HTREEITEM)TVI_FIRST;<br />
BeforeItem = RootItem = NULL;<br />
TVINSERTSTRUCT treeViewInsert;<br />
treeViewInsert.item.mask = TVIF_TEXT;<br />
treeViewInsert.item.pszText = (char*)sNodeName.c_str();<br />
treeViewInsert.item.cchTextMax = sizeof(treeViewInsert.item.pszText)/treeViewInsert.item.pszText[0];<br />
treeViewInsert.hInsertAfter = TVI_ROOT;<br />
treeViewInsert.hParent = NULL;<br />
ParentItem = (HTREEITEM)SendDlgItemMessage(tvHwnd, IDC_TREE1, TVM_INSERTITEM, 0, (LPARAM)&treeViewInsert);<br />
if(ParentItem == NULL)MessageBox(NULL, "aaa", "", MB_OK);<br />
return ParentItem;<br />
}<br />
|
|
|
|
|
Besides the fact that "int iLevel" is not used the rest of the code runs correctly when I have good values like tvHwnd, IDC_TREE1, etc. Therefore I suspect one of your values is incorrect.
|
|
|
|
|
cchTextMax = sNodeName.size()
Kuphryn
|
|
|
|
|
Wow... how did i miss that
|
|
|
|
|
Dear all,
I have MFC application Which As button named Download file ,which pop up a user dialog named "file download". which provides buttons to browse file and start downloading the selected file.
When i press download button it call a dll function to perform the download operation and waits for download to complete.what i need is to close the dialogbox(named file download)whenever the file download completed messagebox pop up .
Manjunath S
GESL
Bangalore
|
|
|
|
|
|
If it's a modal dialog, call EndDialog() . If it's modeless, call DestroyWindow() .
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
and you can se WM_DESTROY
whitesky
|
|
|
|
|
Using the designer to create the main form for an application generated the following code in the .cpp file:
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
System::Threading::Thread::CurrentThread->ApartmentState = System::Threading::ApartmentState::STA;
Application::Run(new DataForm(lpCmdLine));
return 0;
}
The DataForm class has a button which generates a new form:
linkedForm = new LinkedForm() ;
The LinkedForm class exists in the same namespace as the DataForm class.
What needs to be done to allow this child form to see public methods in it's parent, since a DataForm ptr cannot be declared globally? Are there any examples of parent/child form communications of this nature?
Thanks,
MrHonus
|
|
|
|
|
seems this is not a standard MFC program, u might post it to Manage C++/CLI forum.
life is like a box of chocolate,you never know what you r going to get.
|
|
|
|
|
|
Is it CI/C++?
It was created using Visual Studio and .NET, so I guess the answer is yes.
|
|
|
|
|
I have created an ActiveX Control using VC6 with MFC Automation built in. I'm able to add the control to a VB6 form and run it successfully(for most parts : I'm not able to observe any of the events fired within the control). Anyway, the real problem is when I try to use the ActiveX control in a VC6 Dialog based app. it crashes on me at design time, right after I 'Insert ActiveX Control' into the Dialog. It triggers a 'Debug Assertion' within the MS VC6 IDE and then shuts down the IDE. Verrrry frustrating...
I think I may have narrowed it down to the OnDraw method for the control:
Within the Control I have a member called 'configPanel' derived from CDialog, which is used to control runtime settings for the Control. It contains several components: buttons, edit box, check boxes, etc... I've implemented the OnCreate for the Control, as well as for the child 'configPanel'. I'm using the MoveWindow to size and position the 'configPanel'. See code below. This works fine in the VB6 container but won't even place the component in the CDialog container at design time. Note: the code below will work using the GDI functions, but bombs with the 'MoveWindow'. How do I go about rendering the child dialog 'configPane' and its control components(button, edit box, etc...)????
<br />
void CSomeCtrl::OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)<br />
{<br />
CBrush brBackGrn(RGB(255,100,100)); <br />
pdc->FillRect(rcBounds, &brBackGrn);<br />
<br />
CRect rcPanelRect(rcBounds.TopLeft(),CSize(rcBounds.Width(),rcBounds.Height()/4));<br />
<br />
}<br />
Someone please enlighten me!
You are my last, greatest hope...
MissingLinkError
|
|
|
|
|
I am not realy sure the problem but I think you should move:
<br />
CRect rcPanelRect(rcBounds.TopLeft(),CSize(rcBounds.Width(),rcBounds.Height()/4));<br />
configPanel.MoveWindow(rcPanelRect,TRUE);<br />
to OnSize event handler.
|
|
|
|
|
I have a printing application which works quite good for some years now.
It uses a modless abort dialog which can be used to abort the banded printing process. The dialog uses the well known "keep the message pump alive" method which is e.g. described in this article (http://www.codeproject.com/threads/TemplatedLengthyOperation.asp[^].
So the printing process queries an abort method of the dialog continuously which keeps the message handling alive and checks the abort button. This works very good for years now.
But now I want to use a progress bar and an abort button in the toolbar of the print preview view instead of the dialog - but I am not sure if this will work with the same technique like in the abort dialog. I could not find any information about it. Everyone seems to use a dialog.
Has anyone an idea if this works?
|
|
|
|
|
Printing in a background thread and when the UI thread tool button is clicked us PostThreadMessage to inform the printing thread of the abort.
|
|
|
|
|
Thanks for your answer. Of course this would work, but I try not to change how the internal printing routine work. So want to avoid using a thread if it is possible.
|
|
|
|
|
Why is it not compiling?
Errors:
1. (16): error C2079: 'file_op' uses undefined class 'std::basic_fstream<_Elem,_Traits>'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
2. (16): error C2078: too many initializers
3. (17): error C2228: left of '.eof' must have class/struct/union type
4. ..test.cpp(17): fatal error C1903: unable to recover from previous error(s); stopping compilation
test.cpp
#define MAX_LINES_PER_SENTENCE 1000
#include ".\SentenceAr.h"
#include ".\SentenceList.h"
#include <string>
using namespace std;
void main ()
{
char strOutput[MAX_LINES_PER_SENTENCE + 1] = {""};
char strFileToRead[MAX_LINES_PER_SENTENCE + 1] = {"C:\\temp\\testfile.txt"};
int x = NULL;
fstream file_op(strFileToRead,ios::in);
while(!file_op.eof())
{
file_op.getline(strFileToRead,2000);
cout <<strOutput;
} file_op.close();
cout <<endl;
;
file_op.close();
}
The code does not compile even when I try to declare strOutput and strFileToRead as 'string' including the <string>.
Jon
|
|
|
|
|
You forgot to #include <fstream> at the top of your test.cpp file.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
|
Hi,
Can u please say how to get data(text) in the grid control of a property page into another property page.
Thanks in advance.
tejaswini.
|
|
|
|
|
Hey Everyone,
I am developing a application in MFC in which I have 3 CBitmapButton; 1 big BitmapButton over that other 2 BitmapButton but the problem is that when the focus is at the button which is in background, the other 2 button which are on foreground disappear. I want that the 2 button in the foreground always appear in the foreground so that user can see those everytime.
Can somebody help me out with this problem.Thanks for reading.
Vab
Vab
|
|
|
|