|
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
|
|
|
|
|
AFAIK, you can call SetWindowText on the rich edit control, but this is probably inefficient. Try looking up the CRichEditCtrl member StreamIn, or the windows message EM_STREAMIN.
Chris Richardson
|
|
|
|
|
StreamIn seems to work OK. Thanks
|
|
|
|
|
I'm working on a little security program to ensure that invalid CD's do not get inserted into our SOE machines, and to enable this I'm building a little program to manage adding a link to the users start menu.
What I need to know is there an easy way to detect if there is a CD ROM Inserted.
I've been playing with CreateFile for the purpose which is fine, to ascertain that the actual CD that is currently in the Drive is invalid, BUT if there is no disk at all, then a No Disk in CD warning is displayed by the operating system.
Is there a way to disable the Warning(temporarily) or a better way to check for the prescence of a disk?
Thanks for any help.
|
|
|
|
|
Try to call SetErrorMode with SEM_FAILCRITICALERRORS flag. It works with floppies, probably will with CD drive as well.
Tomasz Sowinski -- http://www.shooltz.com
*** Purgamentum init, exit purgamentum ***
|
|
|
|
|
thanks so much... this is perfect..
and to make it normal again after my check I just call
SetErrorMode(0);
|
|
|
|
|
Not exactly. SetErrorMode(0) returns the current error mode - I don't know why that behavior has been removed from MSDN. So the correct way is:
UINT uOldMode = SetErrorMode(0);
SetErrorMode ( uOldMode | SEM_FAILCRITICALERRORS );
SetErrorMode ( uOldMode ); And no I don't know why they didn't just provide a GetErrorMode() API.
--Mike--
"I'd rather you just give me a fish today, because even if you teach me how to fish, I won't do it. I'm lazy." -- Nish
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|