|
hi guys,
i am trying to parse a c++ header file to get the information abt all the classes and their respective functions declared in them.
i am not able to get the position of starting and clsoing braces for a class definition. i know this can be done using stack/recursion, but i couldn't write it.
any help in this reagrd will be highly appreciated.
thanx in advance
mukesh.gupta@promap.co.uk
|
|
|
|
|
This is actually simpler than it would at first seem. You can use the stack based approach but I would go for a more stuctured implementation if I were you.
I have just finished a little project of implementing an interpreter for VB code. It doesn't cover the whole syntax but it does some cool stuff anyway.
I wrote the parsing code using BISON and FLEX. You may have heard of these before. FLEX is a lexical analyser generator and BISON is a parser generator. Both of these program generate valid C code which is ready to be incorporated into your program.
All you do is define the set of tokens used in the language to be parsed and then define a set of ways in which these tokens can be put together in the language. The ways in which the tokens can be used in the language are called the productions. E.g. for C++, the tokens would contain
" , ( ) void int long struct class { } =
And a production for the use of a built in type would be
BuiltInType : INT
| LONG
| DOUBLE
| FLOAT
| VOID
| etc etc etc;
This states that a Built in type is one of the tokens in the list. The "|" means OR. So a built in type is an int OR a aloat OR a void etc.
You can then define, in a BISON script, what C code is to get run when one complete production is found in the input buffer.
Because the script is written by you, you can have the output C code contain anything you want. In your case, when the "IveFoundAMethod" production is run you will want to save the relivant information about that method for use elsewhere in your program.
BISON and FLEX produce code that can be used in VC++. There are some very small changes to make to the generated code but they are only small and fairly self explanitory.
I know that you can find them for download if you search on Yahoo for "BISON FLEX".
Hope this helps
|
|
|
|
|
how can I prevent the user the adjust/resize the window with mouse?
thamks in advanced
guy
|
|
|
|
|
Try to read help for function
SetWindowPos
you have a flag named
SWP_NOSIZE
/REMUS
|
|
|
|
|
thanks remus for your help
i've tried it before and it didn't work,so
i will try again
thanks anyway
|
|
|
|
|
Handle the WM_GETMINMAXINFO message. This message passes you a struct, and you can just fill in the min size and max size with the same values, so the window will remain the same size.
The mouse will still change to the resizing-arrow cursor when you move it over the window border, so to fix that, handle WM_NCHITTEST and if the cursor is over the resizing border, return HTNOWHERE from the message.
|
|
|
|
|
hey remus & mike
i found a solution
i've used the modifystyle function to
remove flags ws_thickframe|ws_maximizebox
and that did the job
thanks again for your support,if you'll ever need
anything you know my address
Guy ,Israel.
|
|
|
|
|
I have derived a small class from CStatic, it does what I want it to so far. But my problem is this:
I need to create a MessageBox everytime the Control is clicked. I've tried using OnLButtonDown() but this doesn't seem to work.
Any help is great
Thx
|
|
|
|
|
Hi Tim,
I think a STATIC window must have the style SS_NOTIFY to notify mouse clicks. So add it to the window's style in your derived class PreCreateWindow or PreSubclassWindow (with ModifyStyle).
You may catch BN_CLICKED reflected message to do what you wish.
Cheers,
Paolo.
|
|
|
|
|
Hi Everyone,
I'm using Visual C++6 and have this problem and hope you can help me out!
What I'm trying to do is to read data from a TEXT FILE and plug the values into a CString, which will be used as a SQL statement.
For example, let's say I have the follwing data in a TEXT FILE:
(the format used for the TEXT File is that the fist row
will be the tablename, and then the following rows will
be the field names and its attributes, and the field
names and attributes will be separated by a comma)
CustomerName
CustID, INTEGER
FirstName, STRING
LastName, STRING
etc...
How can I read the values from the TEXT FILE one by one so at the end, I'll come up with a statement such as:
SQL= "CREATE TABLE CustomerName(CustID INTEGER, FirstName STRING, LastName STRING, etc...)"
I would like to put the reading of the values from the TEXT FILE into a loop so that no matter how many FIELDS the text files contain, the loop will be able to handle it and put all the values into a SQL statment.
For example, if I have the following int the TEXT FILE:
(3 FILEDS and 3 VALUES OF THE FIELD)
CustomerName
CustID, INTEGER
FirstName, STRING
LastName, STRING
Then the following would occur:
SQL="CREATE TABLE CustomerName(CustID INTEGER, FirstName
STRING, LastName STRING)"
BUT if I only have 1 FIELD AND VALUE:
CustomerName
CustID, INTEGER
The reading of the TEXT FILE will be dynamic and the SQL would be:
SQL="CREATE TABLE CustomerName(ID INTEGER)"
Hope you can understand what I'm trying to do.
I've tried to do it in a loop myself but I had some trouble, so If anyone has any solutions, PLMK! Thanks!
Steve
|
|
|
|
|
Hi Steve,
This is not the best code I've ever wrote, but I hope it can help you.
Assuming that the first line is always the table name, you could do something like this:
--struct.txt
CustomerName
CustID, INTEGER
FirstName, STRING
--code
CStdioFile f;
CString sLine, sSql;
int nLine = 0;
sSql = "CREATE TABLE ";
f.Open("struct.txt", CFile::modeRead);
while (f.ReadString(sLine)) {
if (sLine.GetLength()) {
if (++nLine == 1) {
sSql += sLine+'(';
} else {
sLine.Replace(",", "");
sSql += sLine+',';
}
}
}
sSql.SetAt(sSql.GetLength()-1, ')');
f.Close();
AfxMessageBox(sSql);
Regards,
Wanderley
|
|
|
|
|
Hi everyone!
I am in dire need of .ICO and .ICL (Icon Library) spec sheets. I haven't been able to find them anywhere. The main reason for this is the fact that LoadImage() has a bug when loading high-colour icons (though, i do need the .icl specs). fyi. it produces the following error (in debug mode):
HEAP[ZiTest.exe]: Heap block at 00137F20 modified at 00137F54 past requested size of 2c
|
|
|
|
|
I have added icons to the systray, but these icons only have
16 colors, so I want to know that if I can put icons 256 colors icon to the systray.
By the way can I put an CWnd to the systray?
|
|
|
|
|
Hi!
How can I create a application MDI (or SDI) with two panels CListView (like in Windows Commander), (created with CSplitterWnd class and CreateStatic and CreateView functions), with ToolBar (CToolBar or CToolBarCtrl) in CListView (up) and information panel (CStatusBar or CStatusBarCtrl) in CListView (down) in each panel (like in Windows Commander).
Thanks.
|
|
|
|
|
MFC, Win9x, VC6
I have an app the uses a simple hand coded offscreen buffer to animated real-time graphics via the Multimedia timer. I now want to add real-time sound to the app. I want the sound to mimic a Geiger counter. The tone has a fixed frequency, volume and play time of 180ms. On the low end, the tone plays every 1 second. At the other extreme, the high end, the tone plays every 180ms in succession. It is key that a want to change the sound in real-time to match the animation. I tried using the PlaySound() function with a variable pause but the low end pause interrupts my real-time animation. Any ideas? I am surprised at the small amount a code samples and explanation a have found. I am not using DirectX. All suggestions welcome and code samples greatly appreciated!
|
|
|
|
|
Hi all, I need to develop a little configuration program to configure a hardware I developed. I'd like to install the prog in the control panel, like the mouse setup program.
Does someone know how to drive an application to be placed in the control panel ????
Thanks very much...
Carlo.
|
|
|
|
|
|
Does anyone know how I can handle the onafterprint event of an html document that it is contained in a WebBrowser Control (as generated by ClassWizard in VC6)?
The control is on a CDialog-derived dialog. I would like to be able to handle this event in dialog in the same way as I handle OnNavigateComplete2.
|
|
|
|
|
Is there any fast function for sorting an array of strings alfabetically ?
Thanks in advance. Erik
|
|
|
|
|
I can't think of a single call you can make, but there are lots of 'points of interest'.
First tip, don't sort an array of strings - sort a contiguous array of pointers to the strings. This means whatever shifting you do just involves moving bits of the array around, not reallocating strings.
With that in place, there are standard sorting routines you can use. The venerable qsort from the C library works great, though it requires you to set up a 'global' callback. Maybe this could be a static member in C++ if you want to mix.
Inside the comparison callback, its up to you to decide what the order will be - retuning essentially what a strcmp or stricmp returns.
It turns out that there is more than one implementation for the string comparison functions in VC - there is straight C code, and there is much faster 286 code in the Crt\Intel include dir. (I say '286 code' because I think some of this could be even faster with the string ops of a 386 + proc when dealing with big strings).
If you've got control over what proc you are targeting, even a basic framework like this can be way fast, depending of course on the size and similarity of the strings.
STL gurus will probably flame me for this, but it is durn quick!
|
|
|
|
|
Hi,
(I hope this is right forum to ask this question. I didnt see dedicated MFC forum)
I have many modal dialogs, which are used for popups for data input. I'd like them to behave like popup menus, I mean, if user presses outside the dialog it closes. The problem is that I don't know how to catch a message which tells that user presses outside the window. wm_lbuttondown isn't send if user press the mouse outside the window.
Also, there are such many of those dialogs, that I would not want to use the technique some one suggested in his article (here at codeproject) describing the developer style property dialog functionality. And I want the dialogs to be modal.
Any suggestions are welcome... thanks
--memon
|
|
|
|
|
hi,
on the question:
1. generally you can monitor the message queue for lbutton message and do what you whant by using:
SetWindowsHookEx - look it up in the msdn , the windows hooks are a bit complicated...
inf fact i did it once.. but maybe i made a mystake because my program was quite slow... if you want a real working example.. download VNC source at http://www.uk.research.att.com/vnc/
but i think you do not want such a headache
2. (an idea) set the focus the the dialog then the user has two posibilites:
- to click inside the box... you can handle that
- to click outside the box... this means that it will loose the focus.. so you just need to monitor the focus..
3. this is the answer i think...
HWND SetCapture(
HWND hWnd // handle to window
);
msdn: The SetCapture function sets the mouse capture to the specified window belonging to the current thread. Once a window has captured the mouse, all mouse input is directed to that window, regardless of whether the cursor is within the borders of that window. Only one window at a time can capture the mouse.
dont forget to RElease capture
best regards
WarJo
|
|
|
|
|
i want to add some buttons to MS outlook (express) and MS Internet Explorer toolbars.. that can run my program...
i have seen several applications do so like Word and PGP...
if anyone has the knowledge please share it
best regards
WarJo
|
|
|
|
|
Hi,
Is there any short key to go to xxx.cpp if i am in xxx.h file and vice versa.
thanks,
|
|
|
|
|
there is no any standart command in VS for it.
but you can look for add-ins here
http://codeproject.com/macro/
|
|
|
|