|
I see - user can drag the splitter to hide a column. RecalcLayout looks very ugly - maybe it's better to hack into OnMouseMove?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Do you find this ugly?
void CVertSplitter::RecalcLayout() {
CSplitterWnd::RecalcLayout();
int cur, min;
GetColumnInfo(0, cur, min);
if (cur < min) {
SetColumnInfo(0, min, min);
CSplitterWnd::RecalcLayout();
}
}
With the best regards, Vitaly.
|
|
|
|
|
Mea culpa. I didn't realize that RecalcLayout is virtual and you'll have to take the source of CSplitterWnd and make substantial changes.
Cheers,
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I need to run an application from screen saver. When screen saver exists I use this code to launch application.
STARTUPINFO si;
PROCESS_INFORMATION ProcessInformation;
si.cb = sizeof(STARTUPINFO);
si.lpReserved = NULL;
si.lpTitle = NULL;
si.lpDesktop = _T("WinSta0\\Default");
si.dwX = si.dwY = si.dwXSize = si.dwYSize = 0L;
si.dwFlags = 0;;
si.wShowWindow = SW_SHOW;
si.lpReserved2 = NULL;
si.cbReserved2 = 0;
if (::CreateProcess(lpApplicationName, lpszCmdLine, NULL, NULL, FALSE,
0, NULL, NULL, &si, &ProcessInformation))
{
::CloseHandle(ProcessInformation.hProcess);
::CloseHandle(ProcessInformation.hThread);
}
But problem is, this code launch application successfully on Win NT, but I can'tsee launched application on desktop of Win 2k. Another important thing is that when I shutdown my Win 2k system then while shuting down I can see that launched application. I don't know on which desktop this Win 2k launch application.
Please help me in his problem, as I m not getting any idea, as the code is working fine on NT, but is creating problem on Win 2k.
Please help me.
Waiting for reply!
Thanx.
I m really about this Win2k behaviour.
|
|
|
|
|
Just curious: did you try with
si.lpDesktop = NULL; ?
Paolo.
|
|
|
|
|
I'm trying to create a thin frame window, which can still be resized. Problem is that whenever removing the WS_THICKFRAME style from the window I loose the ability to resize the window. How can maintain the resizing capability?
|
|
|
|
|
|
I asked this question yesterday but got no response so will try again. I have used this function successfully in the past, so don't know why I can't get it to work now.
I have the follow file on disk D:\Import\ReadMe.txt, when I search for it, it doesn't get found.
According to help I need to call FindNextFile() after I call FindFile() before I can access any of the other member functions
::SetCurrentDirectory("D:\\Import");
CFileFind Find;
Find.FindFile("ReadMe.txt");
while (Find.FindNextFile())
{
if (!Find.IsDots() &&
!Find.IsDirectory())
{
CString strMsg = Find.GetFilePath();
strMsg += " found.";
AfxMessageBox(strMsg, MB_OK | MB_APPLMODAL | MB_ICONSTOP);
}
}
Find.Close();
Any ideas what I have stuffed up and more importantly any answers to my problem?
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
You should use BOOL value returned from FindFile:
BOOL bWorking = finder.FindFile("D:\\dir\\ReadMe.txt");
while (bWorking)
{
bWorking = finder.FindNextFile();
if (!finder.IsDots() && !finder.IsDirectory())
{
CString strMsg = finder.GetFilePath();
strMsg += " found.";
AfxMessageBox(strMsg, MB_OK | MB_APPLMODAL | MB_ICONSTOP);
}
}
finder.Close();
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Tomasz
thanks for your response. I know about the use of BOOL, laziness stops me from using it in this instance. If I search for *.* instead of ReadMe.txt FindNextFile() will find
. Current Directory
.. Parent Directory
but will fail to find any other files I have in the directory, if I search for a specific file by name it also fails to find it.
I am running this under Windows 2000 Professional SP2 and the actual directory name is D:\DevelopC++\Supplier\Debug\Import. Not sure if the problem is actually being caused by the fact the directory is under the Debug directory used by Visual Studio to create the executable in.
Still completely stumped, as I have been for the last 2 days.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
I know about the use of BOOL, laziness stops me from using it in this instance.
Laziness can hurt here. If your search is going to return exactly one result, your while loop will never execute if you discard the return value of FindFile and use FindNextFile instead. Anyway, CFindFile works perfectly for me - maybe your problems are caused by SetCurrentDirectory? I'd get rid of it and concat mask (*.* or whatever) with dir name.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Going to try your advice now. Funny thing is I originally was concatenating *.* to the directory name and when that wasn't working I changed to SetCurrentDirectory().
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
I've dusted off some old code, and it turns out that you can't use
find.FindFile("...")
while (find.FindNExtFile())
{
}
You'll lose last file returned. You have to play with temp BOOL variable, just like in my first reply to your post.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Tomasz
got it now, thanks for your help. Don't know if I mis-read the help or just can't find it now but it definitely told me to use FindNextFile() before I could do anything with the files.
This is wrong.
FindFile() gets the first file and I can use any member function of CFileFInd to get information on that file, FindNextFile() gets the second, third file etc.
I was screwing myself by not accessing any file information until after I had looked for the second file which didn't exist
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
This is indeed documented in very confusing way. But you have to call FindNextFile before you get the file details with GetFilePath. Otherwise, your app will assert and die.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
it definitely told me to use FindNextFile() before I could do anything with the files. This is wrong.
No, your confusion comes from the bad design of FindNextFile(). In your previous code, you had
while ( finder.FindNextFile(...) ) which seems logical. One would think that FindNextFile() returns false once you iterate through the entire list of files. However, it returns false when you hit the last file, not after you hit the last file. So your test needs to be something like:
BOOL bGo = TRUE;
while ( bGo )
{
bGo = finder.FindNextFile(...);
} So in summary, when FindNextFile() returns FALSE, there is still one more file to process.
--Mike--
http://home.inreach.com/mdunn/
Push the button, Frank.
|
|
|
|
|
I write apps in C++ (using VC++) and often I'm not sure where to palce the classes. For example, if I have a class that interact with a database (CDaoMyClass) I put a reference to this class in the CMyDocument class. Is it right?
I have some trouble in design the class hirerchy for my applycation.
Is there a book that teach how to design a GOOD application with an Object Oriented approach? I mean the Style of programming is important!!!
Thanks!
|
|
|
|
|
For example, if I have a class that interact with a database (CDaoMyClass) I put a reference to this class in the CMyDocument class. Is it right?
What do you mean by a 'reference'? Something like this?
// member of CMyDocument
CDaoMyClass &m_rDaoMyClass;
Is there a book that teach how to design a GOOD application with an Object Oriented approach?
'Design Patterns' by Gamma et al.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
The 'Orthodox' way is to store all persistent data in the applications document. There are problems with doing this:
Eg.
You have an SDI application, with a control bar, nested in control bar is a custom list ctrl. Now from the list ctrl you need to display data stored in the document, this is where MFC becomes very messy.
You do the following,
1/ Get the MainFrame (AfxGetMainWnd and cast to CMainFrame*)
2/ Get the ActiveDocment (GetActiveDocument and cast to CMyDoc)
This completely sucks, however I have lived with this for 7 years.
The other solution is a MVC (Model/View/Controller) pattern, Stingray have developed a class framework implementing MVC (unfortunately I haven't used this). MVC is a much OOD way of the DOC/View metaphor.
Regards
Norm
|
|
|
|
|
I am working with a drawing program. I want to draw rotated ellipse(I dont't want to use rotated DC),but I fond the pen caps can only be round in win98. So I write
"LineTo" myself. But I found its speed was too slow. So please help me, tell where can find fastest code.
thanks to all the programmers who have helped me.
|
|
|
|
|
You can draw rotated ellipse using approximation with Bezier segments. The code below may be just what you want (I've extracted it from some old app - found the code on the net); the degrees parameter controls the rotation
void EllipseEx(CDC &dc, int cx, int cy, int rx, int ry, int degrees)
{
const int Segments = 12;
const int PointCount = 1 + 3 * Segments;
const double Alpha = 3.14159265359 / Segments;
const double Beta = 4 * (1 - cos(Alpha)) / (3 * sin(Alpha));
double px[PointCount], py[PointCount];
double Angle, CosA, SinA;
for (int i = 0; i < Segments; i ++)
{
Angle = 2 * i * Alpha;
CosA = cos(Angle);
SinA = sin(Angle);
int k = 3 * i;
int j = (i == 0) ? 3 * Segments - 1 : k - 1;
px[k] = rx * CosA;
py[k] = ry * SinA;
SinA *= Beta * rx;
CosA *= Beta * ry;
px[j] = px[k] + SinA;
py[j] = py[k] - CosA;
px[k + 1] = px[k] - SinA;
py[k + 1] = py[k] + CosA;
}
px[PointCount - 1] = px[0];
py[PointCount - 1] = py[0];
Angle = 2 * 3.1415927 * degrees / 360;
CosA = cos(Angle);
SinA = sin(Angle);
POINT pt[PointCount];
for (i = 0; i < PointCount; i ++)
{
pt[i].x = cx + (LONG)(0.5 + px[i] * CosA - py[i] * SinA);
pt[i].y = cy + (LONG)(0.5 + px[i] * SinA + py[i] * CosA);
}
PolyBezier(dc, pt, PointCount);
}
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
thank you! Do you have the code of LineTo? Mine is much slower than the CDC::LineTo. And how to create a pen with square cap in win98?
thanks to all the programmers who have helped me.
|
|
|
|
|
Do you have the code of LineTo? Mine is much slower than the CDC::LineTo.
Why do you need your own LineTo?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi, I have programm in VB, where is transparent window. And I rewrite code to MFC. But i have problemm ((. I dont know why ?!, but i see only black color on screen .
Can you help me ?? Here is my code.
_________________________________________
void CMyDialog::DrawScreen(CDC* dc){
CDC *window=GetDesktopWindow()->GetDC();
CDC *drawing = new CDC;
CBitmap *bitmap = new CBitmap;
CBitmap* oldbit;
drawing->CreateCompatibleDC(window);
bitmapa->CreateCompatibleBitmap(window,1050,1004);
oldbit = drawing->SelectObject(bitmap);
dc->BitBlt(0, 0, 100, 100, drawing, 1000, 730, SRCCOPY);
drawing->SelectObject(oldbit);
}
________________________________________
LB
|
|
|
|
|
You're trying to blt from uninitialized bitmap selected into the 'drawing' variable. Can't you just use the 'window' DC as a source?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|