|
|
I've found it... it's only a function so I won't e-mail you... hare you have it:
void CDialogResDlg::OnSizing(UINT fwSide, LPRECT pRect)
{
if (!this->bAllowResizing)
{
if (pRect->bottom - pRect->top != 400) pRect->bottom = pRect->top + 400;
if (pRect->right - pRect->left != 400) pRect->right = pRect->left + 400;
}
CDialog::OnSizing(fwSide, pRect);
}
remember to choose the resizing border in the dialog editor properties...
Hope this helps...
|
|
|
|
|
Hi,
I'm using GetStockObject with SYSTEM_FONT to get the Tahoma font on Win2k/XP, as it's described on its documentation ; why does it return a different font face (and size) ?
|
|
|
|
|
|
I know that in and SDI project normally exists only
a DOC and a VIEW at the same time.
I need to develop a project where I can change some
different views for the same document in order to manage
a not easy UI (lots of controls...).
In this way... I have found the following function:
BOOL CMysDoc::SwitchToView(CRuntimeClass* pNewViewClass)
{
CFrameWnd* pMainWnd = (CFrameWnd*)AfxGetMainWnd();
CView* pOldActiveView = pMainWnd->GetActiveView();
// If we're already displaying this kind of view, no need to go further.
if (pOldActiveView->IsKindOf(pNewViewClass))
return TRUE;
// Set the child window ID of the active view to AFX_IDW_PANE_FIRST.
// This is necessary so that CFrameWnd::RecalcLayout will allocate
// this "first pane" to that portion of the frame window's client
// area not allocated to control bars. Set the child ID of
// the previously active view to some other ID.
::SetWindowLong(pOldActiveView->m_hWnd, GWL_ID, 0);
// create the new view
CCreateContext context;
context.m_pNewViewClass = pNewViewClass;
context.m_pCurrentDoc = this;
CView* pNewView = STATIC_DOWNCAST(CView, pMainWnd->CreateView(&context));
if (pNewView != NULL)
{
// the new view is there, but invisible and not active...
pNewView->ShowWindow(SW_SHOW);
pNewView->OnInitialUpdate();
pMainWnd->SetActiveView(pNewView);
pMainWnd->RecalcLayout();
// destroy the old view...
pOldActiveView->DestroyWindow();
pOldActiveView = NULL;
return TRUE;
}
return FALSE;
}
Using this function I can easily change the current View
but at least one problem remains...
This function destroyes the old view so in my application
exists only one view at the same time.
This causes the not-possibility to centralize Views management.
I'd like to create all views at the start of my application
and to manage all of them in the same time (showing
only one and changing the visualized one when is required).
Is it possible to do that ??
Or only one view can exixts in the SDI project ??
I have also tried to use a sequence of the following instructions
in order to create all views at the start of the application:
// create the new view
CCreateContext context;
context.m_pNewViewClass = pNewViewClass;
context.m_pCurrentDoc = this;
CView* pNewView = STATIC_DOWNCAST(CView, pMainWnd->CreateView(&context));
But it seems to doesn't work !!!
Can someone help me ??
Thanks a lot !!
|
|
|
|
|
Take a look at the other article from the same guy !
You can find it on this site in the Doc/view section. Look at "Switching to other view in a doc-view application".
I used it and I think it's just what you need!
Hope this helps
|
|
|
|
|
Hi, How do i convert Device Units to Pixels?
|
|
|
|
|
Try looking at CDC::DPToLP() .
|
|
|
|
|
|
Hi !
I have a file containing a lot of data (so the file is quite big also) and I want to change the firsts characters in it. In fact, these characters are a counter for blocks of data in the file. So, when I add data, I have to increment this counter but how can I do it without reading all the file, replace the number in memory and write all the file again??? I just want to change the counter and add data at the end of the file!
Any suggestions??
Thanks
|
|
|
|
|
Hi there ... hope that code snippet will help
CString csFile = "c:\\temp\\test.dat";
CFile f;
CFileException e;
TRY
{
// open the file for read/write-access
if(f.Open( csFile, CFile::shareExclusive | CFile::modeReadWrite , &e ) )
{
// read the ... bytes, where the counter is located ....
char pszLine[255] = "";
memset( pszLine, 0, sizeof( pszLine ) );
UINT nBytesRead = f.Read( pszLine, 255 );
// modify the content of the read buffer here ....
// for example : you may increment your data counter
:
:
// write modified buffer content back
f.SeekToBegin();
f.Write( pszLine, nBytesRead );
// move to the end of file and write new data
char pszNewData[1024] = "";
memset( pszNewData, 123, sizeof( pszNewData ) );
f.SeekToEnd();
f.Write( pszNewData, sizeof( pszNewData ) );
f.Close();
}
}
CATCH( CFileException, e )
{
#ifdef _DEBUG
afxDump << "File could not be opened " << e->m_cause << "\n";
#endif
}
END_CATCH
|
|
|
|
|
Use CFile::Seek() to get to the point in the file at which you wish to write.
For example
CFile fileDemo("C:\\Demo.bin", CFile::modeReadWrite | CFile::modeCreate | CFile::modeNoTruncate | CFile::shareDenyWrite);<br />
<br />
long lValue = 123456;<br />
<br />
fileDemo.Seek(OFFSET_FROM_BEGINNING, CFile::begin);<br />
fileDemo.Write(&lValue, sizeof(long));
|
|
|
|
|
Thanks guys !!!
It's exactly what I was looking for
|
|
|
|
|
I have some problem in my code .Due to my inexpereicne iam not able to solve it .
HANDLE hFile;
LPWIN32_FIND_DATA FileData;
hFile=FindFirstFile(str,FileData);
if(hFile==INVALID_HANDLE_VALUE)
{
FindClose(hFile);
return FALSE;
}
else
{
FindClose(hFile);
AfxMessageBox("File Does Exists ");
return TRUE;
}
This is a MFC application .This code is part of CMainFrame class in a fucntion .When the function returns TRUE ,the application crashes .Help me out please
|
|
|
|
|
The answer doesn't immediately spring to mind but, two points which may help...
1) I'm not sure that you have to call FindClose() when the handle returned is INVALID_HANDLE_VALUE.
2) Have you tried using the access() function declared in <io.h>. This can be used to check for the existence of a file too.
|
|
|
|
|
hi there
if you only want to check if the file is existing you can do that like that :
CString csMyFile = "c:\\temp\\some.file.dat";
CFileStatus statusFile;
BOOL bExists = CFile::GetStatus( csMyFile, statusFile );
return( bExists );
But i guess the crash is a result of that :
HANDLE hFile;
LPWIN32_FIND_DATA FileData;
hFile=FindFirstFile(str,FileData);
You should not only pass a pointer to FindFirstFile(..).
It must be a pointer to an existing WIN32_FIND_DATA-struct !!!
If you only pass a pointer to "SomeWhereInMemory" and FindFirstFile starts writing data about an existing file ... it writes to "SomeWhereInMemory" .... and that no good idea !
look at the VC++ MSDN-Help about FindFirstFile :
pFindFileData : Pointer to the WIN32_FIND_DATA structure that receives information about the found file ...
so write it that way :
WIN32_FIND_DATA FileData;
hFile=FindFirstFile(str,&FileData);
and i think it will work .... (without GPF).
|
|
|
|
|
I develop a system for graphic processing, I use TureType Font to output fonts by ploter,I use GetGlyphOutline fuction to get the font's outline, but it's too slowly for ploter to plot the font's outline. I hope to get vector single line font as it in AutoCAD. Can you tell me how to get and use it? thank you very much!
my mail: dirkey@sina.com
dirkey
Jon_Hu
|
|
|
|
|
I've been usinng OpenGL and SDL in many of my apps, but my friends use directX, and claim it's easier and more powerfull. Are they right?
Does anyone else still use the 8051 ?!?!!?
|
|
|
|
|
Well,
they CAN'T say Direct3D is easier than OpenGL...
also, you should check OpenGL updates on pixel shaders to see if one is more powerful than the other.
|
|
|
|
|
snood wrote:
Does anyone else still use the 8051 ?!?!!?
Some of my work projects are targeted at the 80552 which is an 8051 variant.
Does that count?
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
1. I am trying to load a B&W bitmap using LoadBitmap into a CBitmap variable. Because it is a B&W bitmap, I want to then set the foreground and background colors and so that I can load it into a DC and change its colors when I bitblt to the screen to whatever the foreground and background color is. However, this does not seem to work. It almost seems as if when the bitmap loads, it does not load it as B&W even though that is how I designate it in the resource.
Any ideas?
2. I am trying to get the System32 or some other directory using a API call but can't figure out which. Originally I thought maybe SHGetspecialFolderPath but it does not seem to list these directories.
Thank you in advance!
|
|
|
|
|
|
Or try SHGetSpecialFolder.
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
I setfocus same CEdits in a CDialog, but i use "SetFocus()" fail?
|
|
|
|
|
sunson wrote:
I setfocus same CEdits in a CDialog, but i use "SetFocus()" fail?
You aren't very clear, however you can call GetLastError() to see why. You may have passed an invalid HWND .
-Nick Parker
|
|
|
|