|
Here you go :
WIN32_FIND_DATA findData;
HANDLE hFind = FindFirstFile( _T("*.*"), &findData);
if( hFind != INVALID_HANDLE_VALUE)
{
do
{
//
if( ( findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) &&
( _tcscmp( findData.cFileName, _T(".")) != 0 ) &&
( _tcscmp( findData.cFileName, _T("..")) != 0 )
)
{
_tprintf( _T("%s\n"), findData.cFileName);
}
}
while( FindNextFile( hFind, &findData));
FindClose( hFind);
}
this will enumarate all the directories from the current dir. "." and ".." are the current directory and the parent directory. skip them.
|
|
|
|
|
I'm trying to run example 1-3 (shown belob) from the OpenGL programming guide (red book) using visual C++. I linked the necessary OpenGL libraries, OpenGL32.lib GLu32.lib and GLaux.lib. But I still get an error message that it cannot include the header file glut.h. This code is straight out of the book. What am I forgetting to do here?
#include<windows.h>
#include<stdlib.h>
#include<gl glut.h="">
static GLfloat spin = 0.0;
void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_FLAT);
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(spin, 0.0, 0.0, 1.0);
glColor3f(1.0, 1.0, 1.0);
glRectf(-25.0, -25.0, 25.0, 25.0);
glPopMatrix();
glutSwapBuffers();
}
void spinDisplay(void)
{
spin = spin + 2.0;
if(spin > 360.0)
spin = spin - 360;
glutPostRedisplay();
}
void reshape(int w, int h)
{
glViewport(0,0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROTECTION);
glLoadIdentity();
glOrtho(-50.0, 50.0, -50.0, 50.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void mouse(int button, int state, int x, int y)
{
switch (button) {
case GLUT_LEFT_BUTTON:
if (state == GLUT_DOWN)
glutIdleFunc(spinDisplay);
break;
case GLUT_MIDDLE_BUTTON:
if (state == GLUT_DOWN)
glutIdleFunc(NULL);
break;
default:
break;
}
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(250, 250);
glutInitWindowPosition(100, 100);
glutCreateWindow(argv[0]);
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMouseFunc(mouse);
glutMainLoop();
return 0;
}
|
|
|
|
|
Just a wild guess, but I'd say the compiler can't find the header file.
Tip 1: Do a search on your drive to see if you have the glut.h header file. If you do, make sure you add its path to your project settings - and skip Tip 2.
Tip 2: If you don't have glut.h on your drive, get it. As far as I can remember, it comes with the OGL SDK. Check the OGL site for the latest version of the GLUT package.
J
|
|
|
|
|
My edit box code works just fine in debug mode, but it starts behaving very peculiar when I switch to release. Basically, I have a function that looks like this:
void CTerminalCtrl::GetCurrentLine(CString* strLine)
{
int nLines, nLineLength, nRes;
CString temp;
nLines = GetLineCount() - 1;
nLineLength = LineLength();
strLine->Empty();
GetLine(nLines, strLine->GetBuffer(nLineLength));
strLine->ReleaseBuffer();
}
LineLength returns the correct number of characters in the current line, but GetLine always returns zero in release mode, meaning it has copied nothing. strLine will thus be empty.
What is going on here?
Cheers,
/Fredrik
Sonork ID: 100.11430:PhatBoy
|
|
|
|
|
The documentation of CEdit::GetLine says that you've got to write the size of the buffer passed on the first word of that buffer. Alternatively, you can use the overload int GetLine(int nIndex,LPTSTR lpszBuffer,int nMaxLength) which does that job for you. I guess this is what it is causing your problem (in debug mode you probably are being lucky and whatever it is written in the buffer when you call GetLine makes the function satisfied).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Read Joseph M. Newcomers excellent article "Surviving the release"
mfg HintiFlo
|
|
|
|
|
I want to build Win32 Dll which exports only global functions. Client should load this Dll dynamically using LoadLibrary and call it's functions using GetProcAddress.
Internally in this Dll I want to use MFC. So I create Win32 Dynamic-Link Library project in Visual C++ and try to add MFC support to it. When I add MFC includes to the stdafx.h:
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
project is not linked (error message: second definition of DllMain).
How can I add MFC support to Win32 Dll?
|
|
|
|
|
This question was asked here some months ago. I'd say the best way to accomplish this is creating a fresh MFC DLL project and then transferring your Win32 code to it. I did it myself when I needed to add some internal MFC support for a DLL of mine and everything was set up and working in minutes.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank you. Can you give some additional information, please. Suppose I create new VC project of type MFC AppWizard (dll), and select "MFC Extension Dll (using shared MFC DLL)" on step 1. Now I have priject with DllMain. I can add to it classes, if I want to export them I write AFX_EXT_CLASS. But I need to export functions and not classes, as from Win32 Dll. My question now is: how can I add exported functions to MFC Extension Dll?
|
|
|
|
|
You export regular functions just the way you used to when the DLL hadn't MFC support: either with __declspec(dllexport) or resorting to .DEF files. Also, it helps having these functions declared as extern "C" so that you don't have to mess around with name decorating.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
How can i catch the events fired by an ActiveX control without using Class Wizard ?
I'm creating the controls at runtime that's why i can't use the ClassWizard to create the Event Sink Map.
Abdiel Jaramillo
Arango Software International
Panama, Rep. of Panama.
|
|
|
|
|
If creating another AcitveX control is your cup of tea, then you may try to use my class XYDispDriver to handle events. Basically, you create another control as your event handler (you can use ATL or MFC to create the event handler control). Please see my articles for details.
Warning: It only works with non-GUI controls (and the interface has to be derived from IDispatch) and it has been voted the "most hated" method by some ATL "experts".
|
|
|
|
|
I'm not creating another control. I create various CWebBrowser controls in a form view and need to catch the DocumentComplete event but i can't use the EVENT_SINK_MAP macros because i'm creating the controls at runtime.
Thanks
Abdiel Jaramillo
Arango Software International
Panama, Rep. of Panama.
|
|
|
|
|
You'll have to sink your own events. Have a look at knowledge base article Q246247 for starters.
Michael
|
|
|
|
|
This is an offer of encouragement. I had the same problem and worked for several weeks trying to find a good solution. I finally gave up. All the examples and info I could find seemed to assume you know the object at design time.
Runtime discoverable event sinks turned out to be pretty difficult for me. By using the TypeLib calls I was able to get the information for the sink, I could never get the Advise call to work, however.
Please let me know if you find a solution.
Good Luck.
Bill
|
|
|
|
|
Hi all,
Does any body have samples or explanations on how to do this :
A picture is shown in a scollview. When the picture is "bigger" than
the client area, scrollbars appear.
The user can drag a rectangle over the picture. When the rectangle reaches
the border of the client area, the view should scroll in order to allow the
rectangle to reach hidden parts of the picture.
I succeeded in doing this, but I still have a problem to solve :
when the view scrolls, the rectangle doesn't stay at the client
area border ; it scrolls with the picture...
Any idea about the origin of this problem ?
Thx in advance for your help,
Jeje
|
|
|
|
|
This is probably because you are using the client coordinates. In such cases I use the CScrollView::GetScrollPosition and then I'm calculating the rectangle. That is if your top/left corner of your rectangle is out of your client area it is clipped.
Hope this helps.
-widi
-
|
|
|
|
|
Can you please give me more details ?
Do you have any sample code for this ?
Anyway, thanx widi for this info.
I'll investigate this way.
Jeje.
|
|
|
|
|
I'm sending you some sourcecode via E-Mail.
Please stand by......
...
.....
....
...
uploading data....
....
....
-widi
-
|
|
|
|
|
Tanx a lot !
I'll check it asap to see how you proceed.
Nevertheless, I already almost succeed...
In fact I redraw the rectangle and the client area in the OnTimer() function
instead of in OnMouseMove(). SO now, the rectangle stays at the client area
border, but now the problem is that the redraw is not perfect : sometimes
you can see 2 rectangles instead of only one.
Maybe I'll find the solution in the samples you sent !
Thx again,
Jeje.
|
|
|
|
|
I guess I missunderstood your question, sorry.
If you don't want the Rectangle to scroll in your view you can do that:
// this is declared in your class header file
CRect m_rect; // this is the rect you draw
// this goes where you paint your rect
CRect rc(m_rect);
CPoint pnt;
pnt.x = GetScrollPosition(SB_HORZ);
pnt.y = GetScrollPosition(SB_VERT);
rc.OffsetRect(-pnt.x, -pnt.y);
// pDC is your device contect which you get here
pDC->Rectangle (rc);
I think that is what you wanted.
-widi
-
|
|
|
|
|
I have a modeless dialog that is created and popped by an SDI application.
The problem is that the dialog is always topmost. I would like the SDI app to be topmost when I click in its window, placing the popup behind it.
Should a modeless dialog behave like this?
Cheers,
/Fredrik
Sonork ID: 100.11430:PhatBoy
|
|
|
|
|
Try setting CWnd::GetDesktopWindow() as the parent of your modeless dialog, instead of your main window.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
What do you want? That the mainframe will be topmost, or the dialog?
Best Regards...
There is an old saying that if a million monkeys typed on a million keyboards for a million years, eventually all the works of Shakespeare would be produced. Now, thanks to Usenet, we know this is not true.
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|