|
I want my app to search after a EXE to run.
How can my app do that when pressing a button?
------------------------------
CodeCracker - That's me!
------------------------------
|
|
|
|
|
use FindFirstFile and findNextFile.
If you want to use them to recurse through directories then have a self calling function. In this case the function is SearchDir(). I used this particular method because my app always knows the sort of files it is looking for. From this you will see how easy it is to write a single class that does all such searches for you.
Self recursive functions take a little extra care to design. Remember that each instance of the function is entirely independant as far as it's local data is concerned, so any changed data needed in a child has to be passed to the child. Also, the instances will likely trip over each other if you have the function touch global data, I would say to not do this at all, but I can't because I have done it myself deliberately, using 'volatile' data types.
This isn't the fastest method in the world, but its not bad, and it at least shows how the goal is reached. I have left it sort of spread out so its easier to see whats going on.
On my Linux file server I cheat something chronic, I have a process that gathers changes in the /home directory/sub directories so that there are always ready for me to pick up from a text file.
void View::FindMyFiles()
{
CString lString;
lString = "don*.xml" ;
if(FindFile( lString ))
{
//put them through my wonderfull xml parser
//ok, so it occasionally misses a field or
//two, but otherwise, its ok.
}
}
//I like this one seperate from FindMyFiles() so that I can call it
//from other places in my code
bool View::FindFile(CString &FName)
{
CString lString;
m_FindThis = FName;
//change this to recurse or set a/each drive
lString.Format("C:");
//we don't return from this until all of the directories from "C:" have been recursed.
//So you need a way out when what your after is found.
SearchDir(lString);
return TRUE; //TODO: error checking
}
void View::SearchDir(CString sPath)
{
CString sFind,sTemp;
CString sBase,sBase2;
int Done;
WIN32_FIND_DATA lpFindFileData;
HANDLE SearchHandle;
sBase = sPath;
sFind.Format("%s\\*.*",sBase);
SearchHandle = FindFirstFile(sFind,&lpFindFileData);
if( SearchHandle != INVALID_HANDLE_VALUE)
Done = 0;
else
Done = 1;
while( !Done )
{
do
{
if( lpFindFileData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY )
{
sTemp = lpFindFileData.cFileName;
if( (sTemp.Find("..") != -1) || (sTemp.GetLength()==1) )
;
else
{//this is a dir so call SearchDir with modified path
sBase2.Format("%s\\%s",sBase,lpFindFileData.cFileName);
SearchDir(sBase2);
}
}
else
{//do whatever you want to do with a file name
sTemp = lpFindFileData.cFileName;
//if this first is all you wanted then put a getout point here
}
}
while(FindNextFile(SearchHandle,&lpFindFileData));
Done = 1;
}
}
In reality, I nearly always put my file finder as a seperate thread and let it go in the background long before I may need it, updateing a CFileList type data class. Its so impressive to open a dialog and all drives/files even fileserver dirs/files are instantly accessible. Well to me it is, the users don't tend to know its meant to be slower so no one makes me a coffee or brings me a donut....
We do it for the joy of seeing the users struggle.
|
|
|
|
|
I need information about programming plugins techniques. I currently wrote easiest scheme using DLL's with fixed set of exported functions. But it is preferred to have more flexible mechanism with various additional functions.
Any information, url's, etc. are welcome.
|
|
|
|
|
Like COM components? I'm not sure I understand your question.
/moliate
|
|
|
|
|
Well, I'm not very familiar with COM though I know it can be used.
I need general information about plugins architecture, custom application APIs, etc.
Consider I wanna make somewhat like Photoshop 8BF filters. How could I build such a technique? I'd like to see different methods.
Nev
|
|
|
|
|
How to run the command of ["%ProgramFiles%\\Outlook express\\msimn.exe" /mail] under w2k?
|
|
|
|
|
I think you don't need to give the full path
Simply ShellExecute msimn.exe
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
Nish is a BIG fan of Goran Ivanisevic
|
|
|
|
|
But msimn.exe just is a instance.
|
|
|
|
|
I didnt understand what you meant.
But if you mean you want to start a separate instance of msimn.exe when it is already running, that's not possible. msimn.exe will allow only one instance at a time. If you attempt to start it again, it will activate the current instance.
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
Nish is a BIG fan of Goran Ivanisevic
|
|
|
|
|
My english is pool.The "Instance" meant Sample,not the Handle of program.
In my app,I want to run the Windows Default Mail Program.The code is following:
//...................
strDefaultMailCmd = registry.ReadString(strMailReg);
// the Value of strDefaultMailCmd: "%ProgramFiles%\\Outlook Express\\msimn.exe" /mail
if(!strDefaultMailCmd.IsEmpty())
ShellExecute(NULL,"open",strDefaultMailCmd,"",SW_SHOW);
But outlook express is not run.
I want to know how to let windows resolve "%ProgramFiles%"
Thanx
PS: what is "Goran Ivanisevic".
|
|
|
|
|
Z.M Chen wrote:
I want to know how to let windows resolve "%ProgramFiles%"
You need to use SHGetSpecialFolderLocation, SHGetSpecialFolderPath to convert "%ProgramFiles% to the actual path
Z.M Chen wrote:
PS: what is "Goran Ivanisevic".
Goran Ivanisevic is a Croatian Tennis player and probably the owner of the greatest and most lethal first serve in the history of tennis.
Sonork ID 100.9786 voidmain
www.busterboy.org
Nish is a BIG fan of Goran Ivanisevic
|
|
|
|
|
Why do you want to run that application?
I don't Understand....
best Regards
Carlos Antollini.
|
|
|
|
|
I'm trying to change the font of a CTabCtrl. Can anyone help me?
|
|
|
|
|
CTabCtrl is derived from CWnd
You can use CWnd::SetFont
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
Nish is a BIG fan of Goran Ivanisevic
|
|
|
|
|
It worked. Thanks. Now how do I change the font color and make it bold? I searched the MSDN but, being a newbie, I didn't know what I was lookin' for.
|
|
|
|
|
making it bold is easy
just set a suitable nWeight if you are using CreateFont or a suitable lfWeight if you are using CreateFontIndirect and making the font from a LOGFONT
not sure its that easy to change the color
You might have to owner draw or something
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
Nish is a BIG fan of Goran Ivanisevic
|
|
|
|
|
I am using just DOS based C++ and need to know how to redirect the output to go to the printer. This is what I have to work with but am not sure ow to implement it in the .h
ofstream printer("LPT1",ios::out)
printer << data << "line of code";
Any ideas?
|
|
|
|
|
Hi,
Would you please tell me that how to
get and set the rgb color for each pixel in a
bitmap image. In addition, are there getpixel()
and setpixel() functions in CDIB class?
Thanks in Advance!
chen
|
|
|
|
|
Well, you could use GetPixel/SetPixel but that's pretty slow. Any DIBSection wrapper ( which I presume CDIB is ) would however store a pointer to the bitmap data, which you can then access directly.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
Thanks for your reply!
I cannot find the GetPixel() and Setpixel() functions
in CDIB class Lib. Would you please show these source
code?
chen
|
|
|
|
|
I dunno what CDIB is, CDC is the class that has the Set/GetPixel methods, and they are still VERY slow.
Where did you get the CDIB class ? Is it a DIBSECTION wrapper ?
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
The CDIB class i used is wrote by Jorge Lodos (lodos@cigb.edu.cu) in 1998.
But there is no GetPixel and SetPixel function.
It looks like that:
// dib.h
#ifndef _INC_DIB
#define _INC_DIB
/* DIB constants */
#define PALVERSION 0x300
/* Dib Header Marker - used in writing DIBs to files */
#define DIB_HEADER_MARKER ((WORD) ('M' << 8) | 'B')
/* DIB Macros*/
#define RECTWIDTH(lpRect) ((lpRect)->right - (lpRect)->left)
#define RECTHEIGHT(lpRect) ((lpRect)->bottom - (lpRect)->top)
// WIDTHBYTES performs DWORD-aligning of DIB scanlines. The "bits"
// parameter is the bit count for the scanline (biWidth * biBitCount),
// and this macro returns the number of DWORD-aligned bytes needed
// to hold those bits.
#define WIDTHBYTES(bits) (((bits) + 31) / 32 * 4)
class CDib : public CObject
{
DECLARE_DYNAMIC(CDib)
// Constructors
public:
CDib();
public:
CPalette* m_pPalette;
LPBYTE m_pBits;
LPBITMAPINFO m_pBMI;
public:
DWORD Width() const;
DWORD Height() const;
WORD NumColors() const;
BOOL IsValid() const { return (m_pBMI != NULL); }
// Operations
public:
BOOL Paint(HDC, LPRECT, LPRECT) const;
HGLOBAL CopyToHandle() const;
DWORD Save(CFile& file) const;
DWORD Read(CFile& file);
DWORD ReadFromHandle(HGLOBAL hGlobal);
void Invalidate() { Free(); }
virtual void Serialize(CArchive& ar);
/* new added by chen 2001.11.14*/
void SetPixel( int iX, int iY, RGBQUAD& rgbPixel );
RGBQUAD GetPixel(int iX, int iY);
void AssertPosition( int iX, int iY );
// Implementation
public:
virtual ~CDib();
protected:
BOOL CreatePalette();
WORD PaletteSize() const;
void Free();
public:
#ifdef _DEBUG
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
CDib& operator = (CDib& dib);
};
#endif //!_INC_DIB
chen
|
|
|
|
|
Dear Christian,
My really problem is:
In order to change the colour of the text in a bitmap image,
the text is viewed as image pixels. But i want to show the
process of the colour changes. The problem may occured:
can i control the change process of the colour as I needed?
or is there other good methods?
Thanks a lot!
chen
|
|
|
|
|
chen wrote:
In order to change the colour of the text in a bitmap image,
the text is viewed as image pixels. But i want to show the
process of the colour changes. The problem may occured:
can i control the change process of the colour as I needed?
or is there other good methods?
Have I answered this already ? If you want to change the text colour, the reliable way is to draw the text yourself and change the colour yourself. It's also the fastest.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
chen wrote:
The CDIB class i used is wrote by Jorge Lodos (lodos@cigb.edu.cu) in 1998.
But there is no GetPixel and SetPixel function.
Like I said, Get/SetPixel are methods of CDC.
chen wrote:
LPBYTE m_pBits;
There's your pointer to the bitmap data, just like I said. I suggest you write a Get/SetPixel method to work with this, it will be nice and fast then, although not as fast as iterating through in a tight loop.
Do you need to deal with paletised images ? How about 16 bit ? Both of those will be a pain, 24/32 bit is nice and easy.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|