|
C++ doesn't automatically do it for you, but it does have easy ways for you to do it. This statement will cause all the pointers to be initialized to zero:
char *szFileNameOnly[999] = {0};
Chris Richardson
|
|
|
|
|
Thanks for you advice. Can this also be done when the variable has already been declared? If so, how? Cause I'm getting an error when trying to do it.
|
|
|
|
|
If you want to zero all the pointers after the variable has been declared, you can use memset:
memset( szFileNameOnly, 0, sizeof( szFileNameOnly ) );
Chris Richardson
|
|
|
|
|
I have a COM DLL built with VC++6 and it has dialog resources using activex controls such as MsFlexGrid and CTreeCtrl etc.
I have two main applications(AppSimple and AppWithLotOfDlgResources) that can use this dll.
When I use AppSimple to call this Dll, it works fine both in Debug and Release modes.
The problem is when I use AppWithLotOfDlgResources application as the calling program, I am getting "Unsupported operation" only in RELEASE build.
Q. Is there some kind of a conflict in resources between the DLL and the AppWithLotOfDlgResources ?
Please help
Thanks
|
|
|
|
|
When I do stuff like:
POSITION pos = pDoc->GetFirstViewPosition();
while (pos!=NULL)
{
CView* pView = pDoc->GetNextView(pos);
I dont have the second view created or instantiated. Yet the code still works. Is this weird? Does the doc automatically know which views it has even if I dont do:
pChild = (CMDIChildWnd*) pTemplate->CreateNewFrame(pDoc, NULL );
if( pChild == NULL ) return FALSE;
pChild->MDIActivate();
pTemplate->InitialUpdateFrame( pChild, pDoc);
on it? (I do the createframe when I switch views). Am I creating the view here? I've used the first snippet even when the second snippet has not been executed..and it works
Appreciate your help,
ns
|
|
|
|
|
here's my OPENFILENAME struct:
char szFileNames[(MAX_PATH+1)*1000+1];
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = ghWnd;
ofn.hInstance = ghInstance;
ofn.lpstrFilter = "All Files (*.*)\0*.*\0";;
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = NULL;
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFileNames;
ofn.nMaxFile = (MAX_PATH+1)*1000+1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = NULL;
ofn.lpstrInitialDir = "C:\\";
ofn.lpstrTitle = "Open File(s)";
ofn.Flags = OFN_ENABLESIZING | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER | OFN_NODEREFERENCELINKS | OFN_NONETWORKBUTTON;
ofn.nFileOffset = NULL;
ofn.nFileExtension = NULL;
ofn.lpstrDefExt = "*.*";
ofn.lCustData = NULL;
ofn.lpfnHook = NULL;
ofn.lpTemplateName = NULL;
ghWnd is a valid handle to my main window and ghInstance is also a valid handle to my apps memory block
When i run the GetOpenFileName function it returns false, and a call to GetLastError returns "invalid parameter", what am i doing wrong?
Thanks
|
|
|
|
|
Hi,
I am using VC++ 7.0 and am trying to load an icon, which I have as one of my resources, into my button. The button is created dynamically.
Here is the code that I have:
button->Create("SMS", WS_CHILD | WS_VISIBLE | BS_FLAT | BS_ICON,
CRect(0,0,0,0), &m_wndStatusBar, IDC_BUTTON_STATUS_BAR);
button->SetIcon(::LoadIcon(NULL, MAKEINTRESOURCE(IDI_ICON1) ) );
This does not seem to work. I know it worked in VC++ 6.0.
Can anyone help me out here?
Thanking you in anticipation
Rui
|
|
|
|
|
m_ctrlViewList.SetIcon(AfxGetApp()->LoadIcon(IDI_VIEW_LIST));
which m_ctrlViewList is a CButton, more...the icon size is in 32 pixel
==================
BTW, if you want set a other size of icon, like 16*16 size, you can code like this..
//.h file
CImageList m_ButtonImages;
//.cpp file
m_ButtonImages.Create(16,16,ILC_COLOR32 ,2,2); //create you icon list
m_ButtonImages.Add(AfxGetApp()->LoadIcon(IDI_VIEW_ICON ));
m_ButtonImages.Add(AfxGetApp()->LoadIcon(IDI_VIEW_LIST ));
m_ctrlViewIcon.SetIcon( m_ButtonImages.ExtractIcon(0));
m_ctrlViewList.SetIcon(m_ButtonImages.ExtractIcon(1));
modified 21-Aug-12 22:10pm.
|
|
|
|
|
THis is what I want to do: clear a listbox in view2, and repopulate it.
POSITION pos = pDoc->GetFirstViewPosition();
while (pos!=NULL)
{
CView* pView = pDoc->GetNextView(pos);
ASSERT_VALID(pView);
pView->m_list1.DeleteAllItems();
pView->PostMessage(WM_COMMAND, IDC_BUTTONHIDEV2,0);
}
THis line gives an error error C2039: 'm_list1' : is not a member of 'CView'
pView->m_list1.DeleteAllItems();
My View class is called TView1. How do I make this work?
Appreciate your help,
ns
|
|
|
|
|
TView1* pView = (TView1 *)(pDoc->GetNextView(pos)); or if you like the C++ cast syntax:
TView1* pView = static_cast<TView1 *>(pDoc->GetNextView(pos));
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Actually the class that has the listbox is called CDlgList.
With great trepidation I did the cast as
CDlgList* pView =
and it worked!
thank you,
Appreciate your help,
ns
|
|
|
|
|
try casting to ur own view
{
CYourView* pView = (CYourView*)pDoc->GetNextView(pos);
ASSERT_VALID(pView);
pView->m_list1.DeleteAllItems();
pView->PostMessage(WM_COMMAND, IDC_BUTTONHIDEV2,0);
}
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
I have done some test to send and receive bitmap with socket but i have problem;
if somebody has some idea can response.
|
|
|
|
|
For the client server i recomend u using:
http://www.codeproject.com/internet/ndk.asp
The just read the file into a buffer and send it to the client
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hi,
I have embedded a property sheet inside CFormView and have inserted several Property Pages. I want to access data in the first property page from the 2nd Page?
Any suggestions?
Kash
|
|
|
|
|
((CMySheet*)GetParent())->m_Page1
Pavel
Sonork 100.15206
|
|
|
|
|
I want to search the memory when an application is running for a string value and alter it, but i have no idea on how to start. I realise i'd have to look for the WORDs the string is composed off but i dont know how to access the memory, let alone search it. I am trying to make a trainer program for a game. Can anyone help me on this?
Thanks
Kuniva
--------------------------------------------
|
|
|
|
|
Kuniva wrote:
Can anyone help me on this?
No, that's cheating !
BTW, I don't know how to do this, so if anyone can tell us !
Max.
|
|
|
|
|
Try using DebugActiveProcess to atach to the process.
After this call your application will be like a debugger and will be able to stop execution and inspect it's virtual memory.
There is a complete section in the platform SDK dedicated to the debugging API in windows.
Cheers
|
|
|
|
|
How do you catch a connection error in CSocket?? It doesn't seem possible..
CSocket sSocket;
sSocket.Create();
int iCon = sSocket.Connect("some.dns.com", 21);
if(iCon != 0)
MessageBox("Error Connecting");
or
if(iCon == SOCKET_ERROR)
MessageBox("Error Connecting");
Even if the address doesn't exist it will allways return a 0. (success)
I derived my own CSocket class and and over rode OnConnect(int nErrorCode) so that if it returns a error I post the message and if it doesn't error run a function.. it never returns anything..
The only reason I am using CSocket is because I need to use CSocketFile and CArchive..
Any ideas?? Or is this how it's supposed to work?
|
|
|
|
|
Here is internal MFC code executed by the Create() call :
BOOL CAsyncSocket::Create(UINT nSocketPort, int nSocketType,
long lEvent, LPCTSTR lpszSocketAddress)
{
if (Socket(nSocketType, lEvent))
{
if (Bind(nSocketPort,lpszSocketAddress))
return TRUE;
int nResult = GetLastError();
Close();
WSASetLastError(nResult);
}
return FALSE;
}
And you still wonder why it always returns 0. Come on....
From this code, it's also clear you can call either ::GetLastError() or ::WSAGetLastError() to get the actual error.
How low can you go ? (MS retrofuck)
|
|
|
|
|
Thanks! Worked like a champ.
|
|
|
|
|
Hi,
My name is Rui, and i'm developing an MFC application with VC.NET.
I would like to change, by code, the back color of a certain line or item.
I read some articles on the subject, but i still can't, i found some solution very dificult...
Thank you for your time
Rui
|
|
|
|
|
Are here any API function to get serial numbers
or IDs of hardware in computer. (VGA, Memory, HD and so on)
Thank you
Viliam
|
|
|
|
|
Hi All,
I'm trying to implement a message window, like the one in Visual Studio, without the tabs, though. I've got a CDialogBar member in my main frame class, with an embedded rich edit control. How do I send text to a rich edt control programmatically? I was using a list control, but didn't like the way this worked, since it didn't give many formatting options. I thought about using a regular edit control, but then I couldn't do fancy formatting either.
Thanks
Aaron
|
|
|
|