|
TPN wrote:
How to check if file existe (not by trying to open it, fail : not existe or not)
You can use _access() or CFile::GetStatus().
TPN wrote:
How to get the temporary file name which is not coincide with existing files.
Use GetTempFileName().
|
|
|
|
|
Here's how you check if file exists :
CFileFind fileCheckExistance;
CString strPath = "C:\\Test\\myfile.exe";
if ( fileCheckExistance.FindFile( strPath ) )
AfxMessageBox("File exists !");
else
AfxMessageBox("File doesnt exist.");
|
|
|
|
|
thanks to see my question
I hope to use MFC to browse remote directory
my ideal is write one server, one client
when client ask server`s directory
i let server transfer local "BROWSEINFO" to client
and client use it borwse directory function to read
server`s "BROWSEINFO"
but i can`t use socket to transfer "BROWSEINFO" ?
i don`t know what type "BROWSEINFO" is.
or what I think is total worng?
thanks~
Chai-Yuan, Young
chai_yuan@msn.com
|
|
|
|
|
hello i am newbies
i want how to configurate(creat,....) a thread to launche a function that i want to be executed in one part of time?
|
|
|
|
|
Hello...I have a form with some edit controls. there are two modes (1 and 2). In mode 1 some controls should be available for editing, and a button visible and available; and other controls should be unavailable for editing and another button not visible.
Changing to mode 2 invert the availability.
My problem is that I do not know if this is possible to do it at runtime. If this is possible, how do I do it?
I know where to put the code to enable and unenable the controls, but I would like to know what are the visual c++ statements to do this.
Can anyone give me a hand?
Thanks
Eric Manuel Rosales Pena Alfaro
PhD student
Unversity of Essex
Wivenhoe Park
Colchester, CO4 3SQ
Essex, Uk
email: emrosa@essex.ac.uk
tel: +44-01206-87311
|
|
|
|
|
Here are some essential control functions.
EnableWindow()
ShowWindow()
MoveWindow()
SetWindowPos()
Kuphryn
|
|
|
|
|
Hi
I created an MDI application and divided the document into 2 rows, whereby the upper row is divided again into 2 colums (similiar to the irc-client mIRC).
The second row is of type CEditView , the right column of type CListView . That's how I created the splitter windows:
BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
CRect cr;
GetClientRect(&cr);
if(!m_mainSplitter.CreateStatic(this, 2, 1))
{
MessageBox( "Error setting up splitter frames!", "Init Error!", MB_OK | MB_ICONERROR);
return FALSE;
}
if(!m_mainSplitter.CreateView(1, 0, RUNTIME_CLASS(CEditView), CSize(cr.Width(), cr.Height()-iEditHeight), pContext))
{
MessageBox( "Error setting up splitter frames!", "Init Error!", MB_OK | MB_ICONERROR);
return FALSE;
}
if(!m_secSplitter.CreateStatic(&m_mainSplitter, 1,2,WS_CHILD | WS_VISIBLE | WS_BORDER, m_mainSplitter.IdFromRowCol(0, 0)))
{
MessageBox( "Error setting up splitter frames!", "Init Error!", MB_OK | MB_ICONERROR);
return FALSE;
}
if(!m_secSplitter.CreateView(0, 0, RUNTIME_CLASS(CFoxIRCView), CSize(cr.Width()-150, cr.Height()-iEditHeight), pContext))
{
MessageBox( "Error setting up splitter frames!", "Init Error!", MB_OK | MB_ICONERROR);
return FALSE;
}
if(!m_secSplitter.CreateView(0, 1, RUNTIME_CLASS(CListView), CSize(150, cr.Height()-iEditHeight), pContext))
{
MessageBox( "Error setting up splitter frames!", "Init Error!", MB_OK | MB_ICONERROR);
return FALSE;
}
m_mainSplitter.SetRowInfo(0, cr.Height()-iEditHeight, 0);
m_secSplitter.SetColumnInfo(0,cr.Width()-iListWidth,0);
m_secSplitter.SetColumnInfo(1,iListWidth,0);
m_pOutputView = (CFoxIRCView*)m_secSplitter.GetPane(0,0);
m_pNicklistView = (CListView*)m_secSplitter.GetPane(0,1);
m_pCommandView = (CEditView*)m_mainSplitter.GetPane(1,0);
CRichEditCtrl& m_ctlOutput = m_pOutputView->GetRichEditCtrl();
CListCtrl& m_ctlNicklist = m_pNicklistView->GetListCtrl();
CEdit& m_ctlCommand = m_pCommandView->GetEditCtrl();
...
}
But whenever I hit Ctrl+X/C/V inside the EditView or the ListView my app crashes in viewrich.cpp in line 1870 :
COleClientItem* CRichEditDoc::GetPrimarySelectedItem(CView* pView)
{
ASSERT(pView->IsKindOf(RUNTIME_CLASS(CRichEditView)));
return ((CRichEditView*)pView)->GetSelectedItem();
}
Where's the error?
Thanks in advance
Greg
modified 12-Sep-18 21:01pm.
|
|
|
|
|
the basic problem is MFC command routing not going down into the individual views inside mdichildframe, so either fix that
CFrameWnd::OnCmdMsg()
ie cut, paste ,copy is not being handled by each individual view but by either the document or the app.
|
|
|
|
|
in addition
firstly unless you absolutely need COleDocument and CRichEditControl ditch them and go with CDocument and CEditView derived classes. If you need CRichEditView
then you need to be creating one instead of the CEditView.
secondly derive a CSplitterWnd class and override SetActivePane() which will
set the active view and allow command message routing down into the view.
void CIndicatingSplitterWnd::SetActivePane(int row, int col, CWnd* pWnd)
{
// set the focus to the pane
CWnd* pPane = pWnd == NULL ? GetPane(row, col) : pWnd;
if (pPane->IsKindOf(RUNTIME_CLASS(CView)))
{
CFrameWnd* pFrameWnd = GetParentFrame();
ASSERT_VALID(pFrameWnd);
pFrameWnd->SetActiveView((CView*)pPane);
}
else
{
TRACE0("Warning: Next pane is not a view - calling SetFocus.\n");
pPane->SetFocus();
}
}
|
|
|
|
|
and finally
/////////////////////////////////////////////////////////////////////////////
CWnd* CIndicatingSplitterWnd::GetActivePane()
{
// return active view, NULL when no active view
ASSERT_VALID(this);
// attempt to use active view of frame window
CWnd* poActivePane = NULL;
CFrameWnd* pFrameWnd = GetParentFrame();
ASSERT_VALID(pFrameWnd);
poActivePane = pFrameWnd->GetActiveView();
// failing that, use the current focus
if (poActivePane == NULL)
{
poActivePane = GetFocus();
}
// walk it up
if (poActivePane != NULL)
{
while ( (poActivePane->GetParent() != NULL) && (poActivePane->GetParent() != this) )
{
poActivePane = poActivePane->GetParent();
}
}
// make sure the pane is a child pane of the splitter
if (poActivePane != NULL )
{
if (poActivePane->GetParent() != this)
{
poActivePane = NULL;
}
}
return poActivePane;
}
|
|
|
|
|
Thank you VERY much, I will try that later
regards
Greg
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I don't know what the proper terminology for it but I am trying to understand why the little popup window that you get when you are dealing with pointers or strctures, sometimes works and sometimes doesn't. Say you have a setup like this:
struct MyStruct {
int iData;
}
MyStruct mystruct;
then when you type
mystruct. <- here you will get the nice little pop up window..
Anyone knows why it doesn't work sometimes and why it does work?? Help please.. I like that little pop up.. I am using VC6.0 with service pack 5.
I am specially having hard time with double pointers and for my first pointers I get that nice little pop up but not for the second one...
|
|
|
|
|
This intellisense problem is a well known bug in VS6.0+ - think - and this is a guess only - it has something to do with includes. Not sure.
Michael Mogensen.
|
|
|
|
|
I don't know if this was the case in VS6 (since I haven't used it in a while), but I have noticed that VS.Net refuses to give the popup if you have a syntax issue preceding the code you are currently typing. I wouldn't really call that a bug though. Now that I've noticed that it happens, when the box doesn't popup I start looking for a missing brace or semi-colon, etc. Kind of helpful in a way.
I know it doesn't really help you with your problem, but just something to look out for.
--Dean
|
|
|
|
|
You are correct. This is what happens with VS6, too. Syntax errors will kill Intellisense in a hurry!
|
|
|
|
|
|
Some times it is caused by an syntax error occuring before the current point.
Some times the information is just not available yet (try recompile).
Trust in the code Luke. Yea right!
|
|
|
|
|
Hi,
Is there a way to create a modeless dlg that we cannot move so that it always remains at the same place that I have created it?
Thanks
Everything's beautiful if you look at it long enough...
|
|
|
|
|
You can easily do this via your dialog's OnWindowPosChanging() method. When the modeless dialog is created, save it's window rect to a member variable. Then in OnWindowPosChanging(), change the 'x', 'y', 'cx', and 'cy' values of the WINDOWPOS structure.
BEGIN_MESSAGE_MAP(CModelessDlg, CDialog)
//{{AFX_MSG_MAP(CModelessDlg)
//}}AFX_MSG_MAP
ON_WM_WINDOWPOSCHANGING()
END_MESSAGE_MAP()
BOOL CModelessDlg::OnInitDialog()
{
CDialog::OnInitDialog();
GetWindowRect(m_rect);
return TRUE;
}
void CModelessDlg::OnWindowPosChanging( WINDOWPOS* lpwndpos )
{
lpwndpos->x = m_rect.left;
lpwndpos->y = m_rect.top;
lpwndpos->cx = m_rect.Width();
lpwndpos->cy = m_rect.Height();
}
|
|
|
|
|
This is another way to do it. To move the dialog the user should drag the dialog caption. you can override the WM_NCHITTEST message and disable the HTCAPTION result from reaching hte system.
the could should be like this
UINT CMyDlg::OnNcHitTest(CPoint point)
{
UINT hitResult = CDialog::OnNcHitTest(point);
if(hitResult == HTCAPTION)
return HTNOWHERE;
return hitResult;
}
|
|
|
|
|
There is another simple way to do it.
To move the dialog the user must drag the caption bar, thus you can override the WM_NCHITTEST message and disable the system from recognizing that the mouse is in the caption bar. This code shows ho that is done:
UINT CMyDlg::OnNcHitTest(CPoint point)
{
UINT hitResult = CDialog::OnNcHitTest(point);
if(hitResult == HTCAPTION)
return HTNOWHERE;
return hitResult;
}
|
|
|
|
|
If the dialog has a system menu the keyboard can be used to move it, so this isn't good enough. OnGetMinMaxInfo() may do the trick.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Hi,
Here is my problem. I want to give a non-rectangular shape to my dialogbar. So I created a dialog ressource, a CDialogBar derived class and I created my dialog into my CMainFrame class.
In my CDialogBar derived class, I overide OnCreate():
int MyDlgBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialogBar::OnCreate(lpCreateStruct) == -1)
return -1;
// Create a 'CRgn' object
CRgn rgn;
CRect rect;
GetWindowRect(&rect);
rgn.CreateEllipticRgnIndirect(&rect);
// Set the windows region
SetWindowRgn((HRGN)rgn.GetSafeHandle(), TRUE);
// Detach the 'CRgn' object from the region or else the
// 'CRgn' destructor would close the 'HRGN' handle when 'rgn'
// goes out of scope
rgn.Detach();
return 0;
}
The problem is that I can see the shape that I wanted, but the areas where I'm suppose to see the App Background, are not refreshed. I see my desktop unstead.
any ideas?
Thanks;)
Everything's beautiful if you look at it long enough...
|
|
|
|
|
you can try activeskin software .its very easy to modify any shape of window, toolbar, button and many more. its support visual basic and visual c++.
|
|
|
|
|
ok,
Thanks for the answer, but I would like to do it the hard way. Somebody wiser than me said that it's the best way to learn
Regards
Everything's beautiful if you look at it long enough...
|
|
|
|