|
I like this method. Although I think it should be:
GetFileAttribute(szPath) == FILE_ATTRIBUTE_DIRECTORY Thanks for the hint!
Joel Holdsworth
|
|
|
|
|
You are correct about the FILE_ATTRIBUTE_DIRECTORY bit. But you had better use the bitwise and (&) operator, do not check for equality, as a directory can be hidden, readonly, etc.
DWORD attrib = GetFileAttributes(szPath);
if (attrib != (DWORD)-1 && attrib & FILE_ATTRIBUTE_DIRECTORY)
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Yeah I picked up on that, just after I wrote the post!
Joel Holdsworth
|
|
|
|
|
CFileFind, use IsDirectory()
|
|
|
|
|
bool dirExists
(CString strDirectory)
{
TCHAR* fullPath = _tfullpath (NULL, strDirectory, 0);
if (fullPath == NULL)
return (false);
TCHAR szCurrDir [_MAX_PATH];
_tgetcwd (szCurrDir, _MAX_PATH - 1);
long nStatus = _tchdir (fullPath);
_tchdir (szCurrDir);
free (fullPath);
if (nStatus == 0)
return (true);
return (false);
} /ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
|
OpenGL is basically the cross platform version of DirectX correct???
OpenGL is somewhat analogous to Window's GDI API in that both provide a drawing context(and functions), OpenGL being tuned somewhat for 3d rendering and taking better advantage of video card capability???
If true, does this mean it's possible to use OpenGL to output text?
If I were writing a game and I wanted it to be cross platform I could write a COpenGL class which basically had a resembelence to MFC's CDC but also API functions for more advanced 3D stuff?
What i'm actually looking to accomplish is to have a CDC but cross platform...i'm not really concerned with 3d rendering for now, but it's a possibility in the future.
I figure, rather than write a cross platform CDC using Linux/Windows GDI API and making things complicated I could just write a high level wrapper interface around OpenGL functions...also this opens up the possibility for 3D rendering in the future.
Is what i'm looking to accomlish possible? Does it make sense?
Just wanted to get your opinion
Cheers
How do I print my voice mail?
|
|
|
|
|
Hockey wrote:
OpenGL is basically the cross platform version of DirectX correct???
Sort of. OpenGL is similar to Direct3D. It includes only 3D graphics functionality. No 2D graphics, no audio I/O etc.
Hockey wrote:
OpenGL is somewhat analogous to Window's GDI API in that both provide a drawing context(and functions), OpenGL being tuned somewhat for 3d rendering and taking better advantage of video card capability???
Not really. Yes, it is hardware accelerated, but it is 3D graphics only, as opposed to GDI which is 2D graphics only.
Hockey wrote:
Is what i'm looking to accomlish possible? Does it make sense?
It might be possible, but certainly not easy. OpenGL doesn't have any 2D graphics functionality. It's a purely 3D library. Theoretically, you could probably simulate 2D by applying a bitmap texture to a surface that takes up the entire viewport at a Z-depth of 0, but I'm not sure. You would have to implement all of the 2D graphics operations (lines, circles, fills etc...) in software. Hardware acceleration wouldn't be useful because you wouldn't be using any of the 3D accelerated features (not even texture mapping because your texture would have to be stored in system memory so the appliations could write to it), and I'm fairly sure that graphics cards only apply hardware acceleration to OpenGL when running in full-screen exclusive mode, ie. Only one application can use it at once.
It's a good idea in theory, but I'm just not sure its practical. I'd be happy for you to prove me wrong though
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hmmmm...thanks for the reply...some things I didn't know are now cleared up.
Ryan Binns wrote:
Sort of. OpenGL is similar to Direct3D. It includes only 3D graphics functionality. No 2D graphics, no audio I/O etc.
I was afraid of that.
Ryan Binns wrote:
Theoretically, you could probably simulate 2D by applying a bitmap texture to a surface that takes up the entire viewport at a Z-depth of 0, but I'm not sure.
I'm not sure how you mean...so I would have to (using my custom GDI routines) draw to a bitmap, then apply that bitmap as a texture to a surface?
Ryan Binns wrote:
Hardware acceleration wouldn't be useful because you wouldn't be using any of the 3D accelerated features
If I were rendering 3d objects though, it would make a difference???
There is (after much consideration) a very good chance I will need to render 3d objects as well as 2d.
Cheers
How do I print my voice mail?
|
|
|
|
|
Well openGL came before direct X, and was designed from a different standpoint. (direct X was designed to give you quick access to the video card, openGl to give programers a nice interface to 3d hardware. Latter versions of direct X follow more the open GL model) Text can be done in openGL, but unless you want 3d text that you can look at from different angels it isn't really worth it.
It sounds like you want to use SDL or something like it. SDL is a cross platform video library that a lot of free games are using. It provides 2d and 3d graphics and sound, in the form that games needs. It doesn't have a lot of widgets (buttons and the like) so it isn't so good for normal applications.
A different alternative is to use a cross platform widget set along with openGL. (I have no idea what a CDC is so I'm not sure) QT, gtk, or
|
|
|
|
|
Hi,
Microsoft sells a mouse with horizontal scroll capabilities. Does anyone know how to determine horizontal scrolling? I checked the latest help info for OnMouseWheel event, but nothing about horizontal scrolling. Anyone knows?
|
|
|
|
|
When I use AfxBeginThread in a Win32 application, I get this error:
error C3861: 'AfxBeginThread': identifier not found, even with argument-dependent lookup
Not found? When I type AfxBeginThread and then the ( , it lists the parameters for it. Any idea why it is doing this? Any help is appreciated.
-Dev578
|
|
|
|
|
AfxBeginThread is an MFC function. The function essentially wraps up the old C++ _beginthreadex function. If you're only using plain old Win32, you'll need to use this function instead.
Joel Holdsworth
|
|
|
|
|
In addition to Joel's answer, you should also select for 'multi-threaded DLL' in the 'code generation' section of the project's C/C++ properties.
Software Zen: delete this;
|
|
|
|
|
If you are using MFC, have you included afxmt.h in your stdafx.h file?
Joel Holdsworth
|
|
|
|
|
I am trying to create the thread inside a class:
class ThreadClass
{
public:
//...
bool StartThread();
DWORD WINAPI ThreadFunc( LPVOID lpParam );
//...
};
bool ThreadClass::StartThread()
{
DWORD dwThreadId, dwThrdParam = 1;
HANDLE hThread;
hThread = CreateThread(
NULL, // default security attributes
0, // use default stack size
ThreadFunc, // thread function
&dwThrdParam, // argument to thread function
0, // use default creation flags
&dwThreadId); // returns the thread identifier
return true;
}
DWORD WINAPI ThreadClass::ThreadFunc( LPVOID lpParam )
{
//do whatever here
return 0;
}
this produces this error:
error C2664: 'CreateThread' : cannot convert parameter 3 from 'DWORD (LPVOID)' to 'LPTHREAD_START_ROUTINE'
Any ideas why it is doing this / how to fix it? Any help is appreciated.
-Dev578
|
|
|
|
|
Make ThreadFunc a static function.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hi,
I'm an absolute beginner, started learning C++ a while ago. I'm looking for help to make an application that is able to hide winstyles on all windows and break the MDI of existing applications like Photoshop.
If it's not a big request i would ask for schematic code/ideas.
In depth (only speculation, i've no clue where to start):
1. I would like to hide windowborders, scrollbars and other styles on ALL windows (Windows Classic look) because it's not possible by default in Windows (there's no 0 value for the windowborder in display properties/appearance).
AFAIK it would work with a SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) & ~WS_BORDER); and a dll that intercepts window creation msgs. Somebody suggested WH_CBT hook inside the dll.
There are huge stones in the way. It doesn't work without a system-wide hook and there are several other problems with it. For instance WS_BORDER removes the caption too.. I don't want to remove the caption but the whole windowborder. Or WS_THICKFRAME? I don't know.
2. I would like to break the Multiple Document interface of existing applications (like Photoshop).
There is the well-known mIRC. There you can set MDI childs onto the desktop. Speculating: with a system-wide hook, + SetWindowLong(), SetParent() would allow this. But this way the childwindows would loose all contact with their parent application, is it true?
3. My last question is insignificant but i give it a try. I know some facts about why it's not possible to use 32bit PNGs or BMPs (24bit+alpha channel) on WinXP Visual Styles. GDI is XRGB.
But are there any small chances to break this rule? Like AlphaImageFilter script for Internet Explorer. Or.... I dunno.
Excuse me for the n00b/lame questions.
Thanks in advance,
on
|
|
|
|
|
How can I emulate Ctrl+Ins or Shift+Ins (Ctrl+C Ctrl+V) key combinations. I've seen it in one program where it was possible to define your own keys to work with clipboard. How is it implemented?
|
|
|
|
|
You just need to handle the KEY_UP or KEY_DOWN events in your application and then access the clipboard with whichever key combination you want.
store your internet favourites online - www.my-faves.co.uk
|
|
|
|
|
You must have misunderstood me. The thing I want to do is for example I press Ctrl+Shift+P and text from the clipboard appears on the screen (in Edit Box, Notepad, Word, whatever has the focus). And vice versa I pick out some text with the mouse or keyboard press Ctrl+Shift+C and the text saves to clipboard. That's what I want.
|
|
|
|
|
I'm looking for a lightweight reader/writer for XML files (C++)
Requirements:
- links statically
- does not barf on invalid input (detect is ok), but does not need to verify it
I need to serialize a not too complex dat structure.
Any recommendations?
we are here to help each other get through this thing, whatever it is Vonnegut jr.
sighist || Agile Programming | doxygen
|
|
|
|
|
peterchen wrote:
Any recommendations?
Search for pugxml here at CP. Should be just what you want.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
|
Hi,
My purpose is:
- Write a service
- This service must create thread on every process (on every WindowStation)
Problem is:
CreateRemoteThread in MSDN wrote:
Terminal Services isolates each terminal session by design. Therefore,
CreateRemoteThread fails if the target process is in a different session
than the calling process.
If have many users is loging then have many session. I want to
CreateRemoteThread of every session.
My solution is:
- The first, find window station of the process which I must create thread
on it (use WTSEnumerateProcesses)
- The second, use SetProcessWindowStation to assign a window station to the
calling process (is my service). Result my service will operation on the
window station which I must create thread on a process on it.
- Then, use CreateRemoteThread to create thread. Now, CreateRemoteThread is
successful.
Is this solution true ?
Thank in advance.
PTM.
n4_t1
|
|
|
|