|
I create a project where I include a file.h in another folder in the same project.
when I used #include "myfile.h"
the compiler don't find the file.
How can I do for find it ?
Best Regards
youssef
|
|
|
|
|
use
#include "dir/myfile.h"
lazy isn't my middle name.. its my first.. people just keep calling me Mel cause that's what they put on my drivers license. - Mel Feik
|
|
|
|
|
or add the path ( relative path, not absolute ) to the "additional include directories" in the C++ tab of the project settings.
|
|
|
|
|
If the thumb compiler doesn´t find the file because he doesn´t find the file you must show him the file.
Try it @ home. (B&B)
|
|
|
|
|
The workspace pane lists the following function incorrectly:
<br />
void Show(CRect rectTitle, LPCTSTR lpszTitleText, int xoffset = 0, LPRECT lpHoverRect = NULL, const LOGFONT* lpLogFont = NULL, COLORREF crTextClr = CLR_DEFAULT, COLORREF crBackClr = CLR_DEFAULT);<br />
It will say:
<br />
Show(CRect rectTitle, LPCTSTR lpszTitleText, int xoffset)<br />
When double-clicked, VS shows a messagebox saying it can't find the definition(implementation) of this function. (Well, duh...)
When it's changed (LPRECT changed to something like CRect*), the workspace pane will list the function as:
Show(CRect rectTitle, LPCTSTR lpszTitleText,int xoffset, CRect* lpHoverRect, const int LOGFONT)
Again, it goes awry, and this time it screws up bad... VERY bad. Making a
The only way to get a correct listing in the workspace pane is by removing the default-values....
This bug does not influence the compiling, fortunatly, but it makes debugging these botched functions a bit annoying. (select a different function, then scroll to the botched up one.)
|
|
|
|
|
Hello, everybody. I have an application in which I will have a control box with several data to fill in, several data to be updated, and some command buttons. I also like to add menu facilities.
If I used the mfc (exe) wizard application, either I create a single document or a control-box based application. So,
1. How do I include a control box without having a menu command to invoke it, I mean that the control box appears when I start the application.
2. How do I include menues facilities to the control-box based application?
I have been looking the online help, ans some manuals I have got without success.
Thank you very much,
Eric Manuel Rosales Pena Alfaro
PhD student
Unversity of Essex
Wivenhoe Park
Colchester, CO4 3SQ
Essex, Uk
email: emrosa@essex.ac.uk
tel: +44-01206-87311
|
|
|
|
|
I think you need to read about dialogs, CFormView and related topics.
To create an application with a CFormView
with the wizard, create a SDI ( or MDI ) application and on the last panel, select CFormView as the base class of your view class. the wizard will open the resource editor for the form, where you'll place the different controls.
To create a dialog based application.
with the wizard, on the second panel, choose dialog based ( instead of single or multiple document ). and follow the instructions.
For what you want, I'd suggest going with the first choice, use a CFormView base application.
Max.
|
|
|
|
|
Hello all,
I have started programming in VC7 and visiting this excellent website: it's really a code source 'gold mine' plenty of very helpful articles and code samples.
Now, I have read the following FAQ:
Can I use code snippets and programs in my own work?
Yes. Some authors may have specific restrictions on using code in commercial apps such as providing credit in documentation or sending them an email first, but all code can be used for free.
I have noticed though that in many, many articles *there are'nt* restrictions mentioned at all or only inside the source code i can find something like some comment line ie: '(C) 2002 by programmer name' etc.
But the compiler strips the comments out, right? So i think in the final EXE there will not be any reference to the author.
So far it seems to me that PJ Naughter's Freeware Library (http://www.codeproject.com/library/pj.asp) has one of the clearest specifications about the above:
-You are allowed to include the source code in any product (commercial, shareware, freeware or otherwise) when your product is released in binary form.
-You are allowed to modify the source code in any way you want except you cannot modify the copyright details at the top of each module.
-If you want to distribute source code with your application, then you are only allowed to distribute versions released by the author. This is to maintain a single distribution point for the source code.
But in the other articles (those not telling you anything about this stuff)?
I will appreciate very much any opinion/tips in order to be able to correctly reuse the code samples located in this website. As pointed out, i'd like to know especially the correct way to reuse code sampels/snippets not telling any specific and clear restrictions.
for example vould I simply assume in all these situations that it would be right using by default the PJ Naughter's rules?
thanks in advance!
|
|
|
|
|
I'd say put a note in the .readme and the app's about box
Such as "Contains CBlibbleGumbo by Frogstar Scout Industries"
But it's still good manners to email the authors first
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
Hi:
I meet a problem, it has puzzled me for a long time. I create a COM dll which support MFC, several methods was exposured. The implement code of two methods was shown as follow:
STDMETHODIMP CMyComObj::OnConfiguration(long iReserved, BOOL *pbSuccess)<br />
{<br />
AFX_MANAGE_STATE(AfxGetStaticModuleState())<br />
<br />
CMyCfgDlg dlg;<br />
int rtn = dlg.DoModal();<br />
*pbSuccess = (rtn == IDOK) ? TRUE : FALSE;<br />
return S_OK;<br />
}<br />
<br />
STDMETHODIMP CMyComObj::ShowUIFace(long hParentWnd)<br />
{<br />
AFX_MANAGE_STATE(AfxGetStaticModuleState())<br />
<br />
pdlg = new CMyUIDlg();<br />
if(pdlg != NULL)<br />
{<br />
pdlg->Create(ID_MYUIDLG,CWnd::Fromhandle((HWND)hParentWnd));
}<br />
*pbSuccess = (rtn == IDOK) ? TRUE : FALSE;<br />
return S_OK;<br />
}<br />
The problem is in the first method call, the dialog shown normal and I can use TAB switch focus from one control to another control. When I use the second method call, the dialog shown normal but can't use TAB to switch focus(It does not take effect). The reason is virtual function PreTranslateMessage was not be processed, What's wrong? I want "PreTranslateMessage" be called normally.Please help me!!!
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|
|
Sorry, but PreTranslateMessage will not get called inside your dll. You'll have to find another way to do what you want.
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
Hi there!
I’m currently playing with a PICO scope. (it’s a small parallel port oscilloscope that runs at 20KHz max.)
I’m trying to make a custom graphical interface showing the results acquired from the scope (was hoping to use it in a dynamometer project I was planning) . This part of the deal runs great. But I wanted to add a horizontal scroll bar to make navigation trough the data easier. So l borrowed from Roger Allens tutorial. On scrollbars (http://www.codeproject.com/miscctrl/Scrollbar.asp) And everything works almost according to plan. Unfortunately I’m using a quite large data buffer. -16 KB to 512 KB. Ant that’s where things get strange. It seems that things behave quite normal when I’m below 32KB.
But as soon as I get above 32 KB the scrollbar position returns to 0 and starts counting over - When using “SB_THUMBTRACK” and “SB_THUMBPOSITION”
But behaves normal (counts and scrolls all the way up to 512KB) when using all the other “positioning” options (like SB_PAGE & SB_LINE)
The problem looks like the variable holding the bar position has a max of 32768 and than turns over to 0. (but only when dragging the bar) That would be a 16 bit signed variable. But the SCROLLINFO.nPos which I use is a int so that shouldn’t be the problem.
My code is as I said pulled more or less directly from Rogers tutorial and looks like this :
// m_datasize is the size of the collected data 16 KB to 512 KB.
int i_CurPos = GetScrollPos(SB_HORZ);
int iPrevPos = i_CurPos;
CRect myRect;
GetClientRect(&myRect);
switch(nSBCode)
{
case SB_LEFT: i_CurPos = 0;
break;
case SB_RIGHT: i_CurPos = GetDocument()->m_datasize;
break;
case SB_LINELEFT: i_CurPos = max(i_CurPos -6, 0);
break;
case SB_LINERIGHT: i_CurPos = min(i_CurPos + 6,(GetDocument()->m_datasize+
myRect.Width() - 110));
break;
case SB_PAGELEFT: i_CurPos = max(i_CurPos - myRect.Width(), 0);
break;
case SB_PAGERIGHT: i_CurPos = min(i_CurPos + myRect.Width(), (GetDocument()- \
>m_datasize + myRect.Width() - 110)); //- myRect.Width()-1));
break;
// The part that doesn’t work
case SB_THUMBTRACK:
case SB_THUMBPOSITION: i_CurPos = nPos ;
break;
// The part that doesn’t work
}
SetScrollPos(SB_HORZ, i_CurPos);
ScrollWindow(iPrevPos - i_CurPos, 0) ;
A bit messy but hopefully readable
|
|
|
|
|
Sorry I forgot the setup of the scroll bar
Its done like this.
SCROLLINFO si ;
si.cbSize = sizeof(SCROLLINFO) ;
si.fMask = SIF_PAGE | SIF_RANGE ;
si.nPage = myRect.Width() - 110; // The 110 is because I type measurement related info in a small box there.
si.nMax = pDoc->m_datasize + myRect.Width() - 110;
si.nMin = 0 ;
I hope someone can help.
Thanks.
|
|
|
|
|
Where I can find a good Howto to bind a dialog box written in C# (Windows Control Library, DLL-File) in an existing unmanaged MFC-Program with Doc/View-Support? Data exchange should be supported.
Thanx you!
|
|
|
|
|
hello.
Do you have an funcion that gives back "randomized" numbers.
for example:
ranomize(6) should return 0, 1, 2, 3, 4 or 5.
know what I mean?
I hope you can help me.
I need this funktion for a simulation. The objects should decide by themselves in which direction they will go.
) life is fun!
Johannes
//still a newbie
|
|
|
|
|
use the rand function to return a pseudorandom integer in the range 0 to RAND_MAX. Use the srand function to seed the pseudorandom-number generator before calling rand.
|
|
|
|
|
This works for me :
srand( (unsigned)time( NULL ) ); // Initialise rand with the current time to get
// a truly random seed
int ivariable = rand() % 5 // result between 0 and 5
|
|
|
|
|
thanks
Daffy d. wrote:
int ivariable = rand() % 5 // result between 0 and
that is exactly what I needed.
I didn't know how to chance the RAND_MAX value!
You helped me a lot!
) life is fun!
Johannes
//still a newbie
|
|
|
|
|
my treeview is used to display the data stored in a database.. i made a dialog that allows the user to input information.. once the user submits the info, by clicking on the 'ok' button in the dialog, i then store the input info into the database immediately.. once new data are stored in the database, i want to refresh/redraw the tree in the treeview(the tree will display all the data in the database including the newly entered data), but i can't seem to find a way to do it.. can someone plase help me.. thank you!
|
|
|
|
|
I don't remember exactly how (I've not been doing any MFC stuff for a long time now) but you'll probably want to create a method that will query the database and add the records to the TreeView, this then gets called from other CTreeView methods, such as the one that's called when its first initialised. Once its been populated there will be a Clear() method (possibly as part of the underlying CTreeCtrl though) that will empty the TreeView so that you can then re-populate it.
However, if you're adding a single record and you know how it behaves its probably more efficient just to manually add the line into the TreeView rather than the entire db -- once it gets to a significant size it'll be quite slow (depending upon the dbms of course).
Anyway, it may be better to create a method in your CTreeView derived class that adds a single record to the TreeView, this can then be called from another method that queries the entire DB and adds each record. Then you can use this AddRecordToTree() method after your dialog closes and add the record manually, thus avoiding any database querying etc.
Sorry for being quite so vague with everything.
--
Paul
"I need the secure packaging of Jockeys. My boys need a house!"
- Kramer, in "The Chinese Woman" episode of Seinfeld
MS Messenger: paul@oobaloo.co.uk
Sonork: 100.22446
|
|
|
|
|
Hi
I would like to write an Internet explorer plugin such as the search bar of code project. However I have no clue of how about doing it! Could anyone point me to the direction eg reading or any hint about that!
Thanks
Regard,
|
|
|
|
|
|
|
How can I put a main menu created in Resource in a dialog box? And how can I crate the menu handler codes for the sub menu items?
Thank you all
|
|
|
|
|
1) Right-click on dialog template, select "Properties". If Properties dialog select menu ID from Menu combo box.
2) To handle menu items use MFC Class Wizard. If you don't use MFC, handle WM_COMMAND message.
|
|
|
|