|
Does CWnd::SetIcon not work for you? I seem to remember that being the way to do it... heck, if you generate a dummy MFC dialog-based app, I think the dialog class comes with code that sets the icon as you speak of.
I'd look deeper, but I'm at my crummy box at home with no compiler.
Jim Crafton wrote:
¡El diablo está en mis pantalones! ¡Mire, mire!
Even though you've had sig that forever, it's still funny.
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein
|
|
|
|
|
Well I'm not using MFC, so I just use the SendMessage equivalent, but unfortunately all it changes is the window icon - the icon that shows in the Alt/Tab window is different (that's the one from the app's resource icon). I did some more digging but pretty much didn't find much other than to confirm that
::SendMessage( hwnd_, WM_SETICON, ICON_BIG, (LPARAM)winIcon );
works, but curiously if you use
::SendMessage( hwnd_, WM_SETICON, ICON_SMALL, (LPARAM)winIcon );
It doesn't make the change permanent - Wee what fun, the Win32 API is !
And they say size doesn't matter !
So for the moment I think I just give up and settle for changing the Window icon - better than nothing
Cheers
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
|
|
|
|
|
Probably you need to change the registered icon so try this:
SetClassLong(hWnd, GCL_HICON, (LONG) LoadIcon(hinst, MAKEINTRESOURCE(IDC_MYICON)));
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
My first working program was able to do that. It's not really hard.
I think it was SetIcon(HICON, BOOL). If you generated an MFC-based project, you'll find an example at the end of YourProjectDlg::InitDialog(), just before the TODO remark.
Somewhere in the code of your dialog (but I think it is also possible in SDIs or MDIs, but not how;P)(as long as it's in a function like YouProjectDlg::MemberFunction(...)) you put the following code:
m_hIcon = AfxGetApp->LoadIcon(IDI_Your_Icon);
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
I just copied it from OnInitDialog. I don't know what the function of the double execution of SetIcon is, but 'ey, it works, and that's what you want, don't you?
If you just want to show the small version of the icon (16x16), you should leave SetIcon(m_hIcon, FALSE); . (Why that one? That one actually means "Set the NON-big version of m_hIcon", since it's something like SetIcon (HICON TheIcon, BOOL BigIcon))
I stored the icon handle into m_hIcon, because that's the standard member variable to store the handle of the dialog's current icon (yes, of a dialog, also here I don't know anything about SDI/MDI stuff). But I don't think it will be harmful to use a local variable for that.
|
|
|
|
|
Hi,
I was opening a dialog with controls by left clicking on the parent window of my SDI application, but now I want my parent window to contain the dialog. That’s why in the CMyTreeView, I changed the constructor to the following
CMyTreeView::CMyTreeView() : CFormView(IDD_DIALOG1)
{
// TODO: add construction code here
}
where IDD_DIALOG1 is the dialog that I want in the CtreeView.
But, above doesn’t work, and I keep getting run time error at line CFormView::Create(..) in the file ViewForm.cpp
Can anyone tell me how I can convert my program, so that I can keep most of my codes unchanged (I’m doing all the processing in the dialog class and I don’t want to move them to the view class)
Please advise soon
Binayak
|
|
|
|
|
Does anybody have any information/links/etc about MFC classes CControlBar, CDockBar and CDockContext? On CodeProject, CodeGuru and other internet resources there are only few articles with obsolete information.
|
|
|
|
|
You can search "CSizingBar" via Google.
Good luck!
|
|
|
|
|
|
I have a TCP server which starts a thread that loops to accept connections. The funtion the "Acceptor" is spawned from then uses WaitForSingleObject() to wait for the acceptor to return for any reason (there is actually first a suicideEvent which is triggered when user pressed CTRL-c and that even is also waited for with WaitForSingleObject(), then a flag is set to let the acceptor know that it needs to exit). This way, it works fine cause i can close the handle to the acceptor thread once WaitForSingleObject returned. But then...
The Acceptor spins every new connection off into its own clientthread. I keep a list of thread handles in a vector. So when a new thread is created, i add the handle to the vector. Now the problem is... I read on MSDN that the right way to actually terminate a thread is to let it return or call ExitThread and then to use CloseHandle() to remove it from memory.. cause if not all handles are closed, it won't be removed from memory, and i think that would be a gigantic problem for a tcp server since that way, everytime a connection is lost, the memory the thread took up is wasted and stays allocated. Cause my problem is i don't know how/when to use CloseHandle now... When a client thread terminates, i have no way to see it did this... I thought about using WaitForSingleObject or WaitForMultipleObjects again but.. i don't see how its possible to implement this because the acceptor can't be waiting to see which threads have finished...
I'll provide a basic sketch of my code (very much simplified):
void StartServer()
{
}
DWORD WINAPI Acceptor(void*)
{
}
DWORD WINAPI Clientthread(void*)
{
}
I hope i made the problem clear... i really have tried to think of several solutions but they all did not turn out well in the end. If anyone has any suggestions, please let me know.
Many thanks
Kuniva
--------------------------------------------
|
|
|
|
|
If you don't need to wait on the thread's handle, just close it straight after you create it.
|
|
|
|
|
When I build any new VC++ application, the File Save dialog, Print dialog, etc. prompts are in German.
e.g. "Save Changes to Untitled" becomes "Anderung in Unbenannt speichem" ... "untitled.txt" becomes "Unbenannt.txt"
Did I accidently select this somewhere ? or has a dll been replaced by a German version ? ...
(This is not a project setting since it affects any project I build even freshly downloaded Microsoft sample programs)
Any help to get this back into English would be much appreciated.
|
|
|
|
|
The answer ...
This was caused by the file mfc42loc.dll being present in c:\windows\system ... it was the german language version. For English systems this file should not be present.
It is interesting to delete this file since any application that uses mfc42.dll also loads this file and locks it against deletion. So need to come up in DOS mode to delete it.
|
|
|
|
|
for 16 bits or higher bitmap, doc says there is no color table inside bitmap file.
my Q is: where is its color table for those kinds of bitmaps? it should be in system, how to access it?
thx
includeh10
|
|
|
|
|
There's no palette in these cases: colors are given in RGB format, with more or less bits devoted to each color channel depending on the number of bits per pixel. Check the docs for BITMAPINFOHEADER for further info.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
How can I programmatically force a full screen console window in C?
There, wasn't hard was it.
"werewnt we going to run off and start a convent on as islandf]" -David Wulff, again on MSN while plastered...
Jonathan 'nonny' Newman
Homepage [www.nonny.com] [^]
Bob Chum Dev site [^]
|
|
|
|
|
I've googled this Usenet article[^] down, which does the trick by simulating the ALT-ENTER keystrokes. It is Delhpi, but easily translatable to C++.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Cheers, I'd already found a fake Alt Enter sequence on another site. But thanks anyway
"werewnt we going to run off and start a convent on as islandf]" -David Wulff, again on MSN while plastered...
Jonathan 'nonny' Newman
Homepage [www.nonny.com] [^]
Bob Chum Dev site [^]
|
|
|
|
|
I posted this problem before, but no one can help me...plz it's urgent!
Hi, in my MFC app I have a template class like this:
<br />
template < class BASE ><br />
class CBWnd : public BASE {<br />
public:<br />
CBWnd(){};<br />
CBWnd(LPCTSTR s, CWnd *p):BASE(s, p){};<br />
CBWnd(UINT n, CWnd *p):BASE(n, p){};<br />
CBWnd(LPCTSTR s):BASE(s){};<br />
CBWnd(UINT n):BASE(n){}; <br />
};<br />
When I derive a class from an MFC one a make this:
<br />
class CMyButton : public CBWnd < CButton > {};<br />
<br />
class CMyDialog : public CBWnd < CDialog > <br />
{<br />
CMyDialog(LPCTSTR s, CWnd *p):CBWnd< CDialog >(s, p){};<br />
};<br />
In the contructors of CMyButton and CMyDialog I need to pass the parameters (for example the template ID and the parent window of derived a dialog) to the base class (CDialog, CButton and so on...that's why all constructors).
This code works fine on Visual Studio 6 but doesn't compile on Visual Studio 2003 because this compiler check all the CBWnd constructors (VS6 check only the used ones...)and if there isn't an implementation in the other classes (CMyButton, CMyDialog ecc...)
of the called one it generates an error...
Plz help me!
|
|
|
|
|
What is an error?
When I look into yours CBWnd(LPCTSTR s, CWnd *p):BASE(s, p){}; I see it should be failing on CButton -- CButton doesn't have CButton(s, p) constructor overload...
|
|
|
|
|
Ummm... I don't have a MSVC 7.0 compiler handy, but what you say seems like a gross bug in it --only actually called member functions should be instantiated. It'd be great if you could reproduce the error in a simple program (hopefully, whitout any MFC mess, just bare classes and constructors).
In the meantime, you can try the following:
template <class BASE>
class CBWnd : public BASE {
public:
CBWnd(){};
template <typename T0> CBwnd(const T0& t0):BASE(to){}
template <typename T0,typename T1> CBwnd(const T0& t0,const T1&t1):BASE(t0,t1){}
template <typename T0,typename T1,typename T2> CBwnd(const T0& t0,const T1& t1,const T2& t2):BASE(t0,t1,t2){}
};
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
From my MFC program I want to pipe XML data to the internet explorer. To make it clear, if I press a button an Internet Explorer window will pop up and where I'll show the XML generated from my program.
How do I do that?
Please help
Binayak
|
|
|
|
|
You don’t necessarily have to directly integrate your program with IE to display XML. One solution is to write the XML data into a file. Then start the iexplore.exe process and give it the filename of your XML file as a parameter. IE will come up with your XML data displayed.
Lorenz Prem
Microsoft Corporation
|
|
|
|
|
I just finished writing a class which should allow you to use a CArchive with a CBlockingSocket class. The same way CArchive works with CSocket, except this one is built on CBlockingSocket which doesn't implement 16-bit functions like CSocket.
Has anyone else tried this or have any knowledge on it? If so, are there any caviates with doing it this way? I've posed my code below for your paruzal:
The class name is CBlockingSocketFile and it emulates functionality in a CFile object. Basically so you can serialize to a CArchive and have it be transmitted across TCP/IP.
Here's the header file:
#define BLOCK_SOCK_TIMEOUT 15
class CBlockingSocketFile : public CFile
{
DECLARE_DYNAMIC(CBlockingSocketFile)
public:
CBlockingSocketFile(CBlockingSocket *pNewSocket);
virtual ~CBlockingSocketFile();
public:
CBlockingSocket * pSocket;
virtual UINT Read(void * pBuffer, UINT nBytes);
virtual void Write(const void* pBuffer, UINT nBytes);
virtual void Close();
private:
virtual BOOL Open(LPCTSTR lpszFileName, UINT nOpenFlags, CFileException* pError = NULL);
virtual CFile* Duplicate() const;
virtual DWORD GetPosition() const;
virtual LONG Seek(LONG lOff, UINT nFrom);
virtual void SetLength(DWORD dwNewLen);
virtual DWORD GetLength() const;
virtual void LockRange(DWORD dwPos, DWORD dwCount);
virtual void UnlockRange(DWORD dwPos, DWORD dwCount);
virtual void Flush();
virtual void Abort();
};
And here's the source file:
IMPLEMENT_DYNAMIC(CBlockingSocketFile, CFile);
CBlockingSocketFile::CBlockingSocketFile(CBlockingSocket *pNewSocket)
{
if(pNewSocket == NULL) {
DEBUG_LOG("CBlockingSocketFile constructor: NULL pointer assignment.");
AfxThrowUserException();
}
pSocket = pNewSocket;
}
CBlockingSocketFile::~CBlockingSocketFile()
{
}
UINT CBlockingSocketFile::Read(void *pBuffer, UINT nBytes)
{
return pSocket->Receive((char *)pBuffer, (const int)nBytes, BLOCK_SOCK_TIMEOUT);
}
void CBlockingSocketFile::Write(const void *pBuffer, UINT nBytes)
{
pSocket->Write((const char*)pBuffer, (const int)nBytes, BLOCK_SOCK_TIMEOUT);
}
void CBlockingSocketFile::Close()
{
pSocket->Close();
}
BOOL Open(LPCTSTR lpszFileName, UINT nOpenFlags, CFileException* pError = NULL)
{
return false;
}
CFile* Duplicate(){return NULL;}
DWORD GetPosition(){return 0;}
LONG Seek(LONG lOff, UINT nFrom){return 0;}
void SetLength(DWORD dwNewLen){}
DWORD GetLength(){return 0;}
void LockRange(DWORD dwPos, DWORD dwCount){}
void UnlockRange(DWORD dwPos, DWORD dwCount){}
void Flush(){}
void Abort(){}
Any input would be much appreciated
Mike Ellertson
|
|
|
|
|
he he, ok I'm embarrased. I had the first code post jacked up... fault slip of the mind
Here's the corrected source file:
IMPLEMENT_DYNAMIC(CBlockingSocketFile, CFile);
CBlockingSocketFile::CBlockingSocketFile(CBlockingSocket *pNewSocket)
{
if(pNewSocket == NULL) {
DEBUG_LOG("CBlockingSocketFile constructor: NULL pointer assignment.");
AfxThrowUserException();
}
pSocket = pNewSocket;
}
CBlockingSocketFile::~CBlockingSocketFile()
{
}
UINT CBlockingSocketFile::Read(void *pBuffer, UINT nBytes)
{
return pSocket->Receive((char *)pBuffer, (const int)nBytes, BLOCK_SOCK_TIMEOUT);
}
void CBlockingSocketFile::Write(const void *pBuffer, UINT nBytes)
{
pSocket->Write((const char*)pBuffer, (const int)nBytes, BLOCK_SOCK_TIMEOUT);
}
void CBlockingSocketFile::Close()
{
pSocket->Close();
}
BOOL CBlockingSocketFile::Open(LPCTSTR lpszFileName, UINT nOpenFlags, CFileException* pError){ return false; }
CFile* CBlockingSocketFile::Duplicate() const {return NULL;}
DWORD CBlockingSocketFile::GetPosition() const {return 0;}
LONG CBlockingSocketFile::Seek(LONG lOff, UINT nFrom){return 0;}
void CBlockingSocketFile::SetLength(DWORD dwNewLen){}
DWORD CBlockingSocketFile::GetLength() const {return 0;}
void CBlockingSocketFile::LockRange(DWORD dwPos, DWORD dwCount){}
void CBlockingSocketFile::UnlockRange(DWORD dwPos, DWORD dwCount){}
void CBlockingSocketFile::Flush(){}
void CBlockingSocketFile::Abort(){}
Mike Ellertson
|
|
|
|
|
Hi
When i insert component like the MicrosoftBrowser, the studio automatically creates a wrapper class for the control, and in this wrapper class there is a function call:
CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID)
does anyone know what this does? Since i would like to implement this in pure win32api without any intervention from Microsoft Visual studio or wizard! Any constructive suggestion are highly appreciated.
Regard,
|
|
|
|
|