|
Im sorry thats not what i was looking for
that is how to change the icon of the window(which i already knew), I want to know how to progmatically change the default icon of an exe, the way a resource hacker would. and when i say the default icon of the exe im talking about the icon that would be showing up in explorer.
|
|
|
|
|
oooooh. How does explorer decide what icon to display? It will automatically pull the main window's icon out and use that as the display icon, at least if it's compiled in MFC (or MFC is packaging the EXE with explorer information in it). Short answer: no f*ing idea.
augy
|
|
|
|
|
To change icon of an exe, you need to overwrite it's icon resource. But first you need to determine default icon, to do that you need programs like Resource Hacker. Once you have found ID of default icon, you can easily update resource. Just follow this article and MSDN.
ARSALAN MALIK
|
|
|
|
|
Archer282 wrote:
Does anyone know of any articals or examples that show how to change the defualt icon of an exe?
Well the "default" icon, the one shown by explorer, is always the first icon in the executable file. So all you have to do is edit the first icon. Is the icon in your executable? If so, use the resource editor. If it's in a separate executable, you'll need to use the BeginUpdateResource() etc. methods to access it at runtime.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hey all,
I am trying to write a better numerical edit control for Chris' MFC Grid[^] and I just want to clear up a question I am having about the localization of negative numbers. According to MSDN[^] when using the GetLocaleInfo function with the LOCALE_INEGNUMBER type, one of the formats is to have the number surrounded by brackets
(1.1) If this is the case for the locale, does the locale also have a negative sign (LOCALE_SNEGATIVESIGN ) that has to be handled, or do users always enter negative numbers by using the brackets?
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
I don't think there is any automatic locale based parsing.
You would catch '(' or '-' for numeric fields and treat as negative based on GetLocaleInfo(LOCALE_INEGNUMBER).
For output formatting i would look at GetNumberFormat() and GetCurrencyFormat() ... you ARE going to add a flag for entering currency values right ... a REAL 'better numerical edit control' would.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
cmk wrote:
a REAL 'better numerical edit control'
LOL
I love the way you put the quotes marks around that. There are so many attempts at a 'better' numerical edit controls, and most fall over flat on their faces when faced with a certain situation (WM_PASTE being the most common shortfall). While I may not write the "end all and be all" of numeric edit controls, it will definitely be better than the one currently supplied with the grid, which is a plain edit control with the ES_NUMBER style.
Thanks for the info, I will have to try and see what I can do with it
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
I am trying to pop up a dialog to loop a gif image while my program does processing work. The problem is, the thread I'm creating doesn't pop up as soon as it's created, and placing breakpoints in InitInstance and ExitInstance reveals that they aren't being called when I call my CWinThread-drived class's CreateThread() method. What explanations exist for this behavior? I have tried versions of my CWinThread class which do and don't override the Run() method. It's a very simple problem which hopefully has a very simple solution =]
I found an article[^] on code guru that deals with my exact issue. I've tried to imitate the behavior of my code to match the article's code as much as possible, but I still cannot get the thread to work.
Here is the .cpp file of my CWinThread class, CInterface
<br />
<br />
IMPLEMENT_DYNCREATE(CInterface, CWinThread)<br />
<br />
<br />
int CInterface::ExitInstance()<br />
{<br />
return CWinThread::ExitInstance();<br />
}<br />
<br />
BOOL CInterface::InitInstance()<br />
{<br />
return TRUE;<br />
}<br />
<br />
void CInterface::KillInterface()<br />
{<br />
if (m_pD.m_hWnd)<br />
{<br />
m_pD.PostMessage(WM_COMMAND, IDCANCEL);<br />
}<br />
}<br />
<br />
int CInterface::Run()<br />
{<br />
m_pD.DoModal();<br />
if (m_pParent)<br />
m_pParent->PostMessage(WM_KILLINTERFACING);<br />
<br />
return 0;<br />
}<br />
<br />
Any ideas?
Thanks alot,
augy
|
|
|
|
|
I've stepped through my code very carefully, and I'll describe exactly what happens.
Here is the high level of the code that I'm debugging. BeginInterfacing() is the function that creates the child thread which plays the animated gif file, and EndInterfacing destroys it. This code is all happening within an event handler from a dialog.
<br />
m_pParent->BeginInterfacing();<br />
m_pID->GetWindowText(m_pParent->m_strName);<br />
m_pPass->GetWindowText(m_pParent->m_strPass);<br />
m_pParent->m_strName.Remove(' ');<br />
<br />
m_pParent->m_pSub = new CSubscriber(m_pParent->m_strName);<br />
<br />
if (!m_pParent->m_pSub->VerifyPassword(m_pParent->m_strPass))<br />
{<br />
m_pParent->EndInterfacing();<br />
MessageBox("Invalid Password", "Invalid Password", MB_OK|MB_ICONSTOP);<br />
delete m_pParent->m_pSub;<br />
m_pParent->m_pSub = NULL;<br />
return -1;<br />
}<br />
m_pParent->EndInterfacing();<br />
If I step over BeginInterfacing, no dialog box comes up and none of my breakpoints are triggered (I have them in Run(), EndInterfacing(), and DoModal() of the dialog box that the child thread creates). I can step through until the line
m_pParent->m_pSub = new CSubscriber(m_pParent->m_strName);<br />
When I try to F10 over this line, my breakpoint in Run() of my CWinThread class is triggered:
int CInterface::Run()<br />
{<br />
m_pD.DoModal();<br />
if (m_pParent)<br />
m_pParent->PostMessage(WM_KILLINTERFACING);<br />
<br />
return 0;<br />
}<br />
m_pD is the dialog that will loop the gif file.
Next, I step into DoModal....
if (hWndParent != NULL && ::IsWindowEnabled(hWndParent))<br />
{<br />
::EnableWindow(hWndParent, FALSE);<br />
bEnableParent = TRUE;<br />
}<br />
<br />
TRY<br />
{<br />
AfxHookWindowCreate(this);<br />
At the line ::EnableWindow(hWndParent, FALSE), execution seems to switch back to where it left off in the top level function, and
m_pParent->m_pSub = new CSubscriber(m_pParent->m_strName);
gets executed next. In fact, execution never returns to where it left off in DoModal() (or any other part of the child thread) until much later, where it goes right back to bEnableParent = TRUE and then creates the modal dialog box normally, but of course it does this at a time I can't pin down and so I have this modal dialog box looping a gif without any way to stop it, so I have to CTRL+ALT+DEL the program, or stop debugging.
The thing I would really like to figure out is why the thread stopped where it did (in the middle of DoModal) and then decided to start back up again when the main thread isn't doing any processing.
Here are Begin and End Interfacing, just for completeness:
void ClassNameProtected::BeginInterfacing()<br />
{<br />
if (m_bBI)<br />
{<br />
return;<br />
}<br />
<br />
if(!m_pI)<br />
{<br />
m_pI = new CInterface(this);<br />
m_pI->CreateThread();<br />
m_pI->SetThreadPriority(THREAD_PRIORITY_HIGHEST);<br />
}<br />
<br />
m_bBI = TRUE;<br />
}<br />
<br />
void ClassNameProtected::EndInterfacing()<br />
{<br />
if (!m_bBI) return;<br />
<br />
m_pI->KillInterface();<br />
<br />
m_bBI = FALSE;<br />
}<br />
<br />
void CInterface::KillInterface()<br />
{<br />
if (m_pD.m_hWnd)<br />
{<br />
m_pD.PostMessage(WM_COMMAND, IDCANCEL);<br />
}<br />
}<br />
<br />
of course, KillInterface() never works because the DoModal() code has stopped before actually creating a window, and so the PostMessage never goes through. Thus, DoModal() never stops, so the Run() function never gets past the DoModal() statement, so the WM_KILLINTERFACING message never gets sent to the ClassNameProtected message pump. ClassNameProtected has a handler which attempts to stop the child thread from processing and then delete the CWinThread object and set m_pI to NULL. That never happens, so my child thread's dialog is now modally looping a gif and my program can't get out.
*exhales*
So, I'll ask again...
any ideas?
|
|
|
|
|
I'm using the CAsyncsocket Receive to receive a string into a BYTE buffer. Now I want to parse out the data into a structure. One of the stucture items is an int.
So my structure is like this (this is an example)
<br />
struct myMsg {<br />
BYTE START[4];<br />
int bLen;<br />
int hLen;<br />
}<br />
My receive function is setup like this:
BOOL bRetCode;<br />
DWORD dwBytesToRead;<br />
<br />
bRetCode = m_sConnectSocket.IOCtl(FIONREAD, &dwBytesToRead);<br />
<br />
BYTE* RecvBuffer = new BYTE[(int)dwBytesToRead];<br />
<br />
m_sConnectSocket.Receive(RecvBuffer, sizeof(RecvBuffer));<br />
<br />
onParseData(RecvBuffer, sizeof(RecvBuffer));<br />
I'm having problems moving bLen into the structure from the BYTE array.
I'm trying to do it like this:
int CLAGCICDlg::onParseData(BYTE* dataBuffer, int bufferSize)<br />
<br />
BYTE* mybuffer = dataBuffer;<br />
myMsg myStuff;<br />
<br />
memcpy(myStuff.START, dataBuffer, 4);<br />
myStuff.BlockLen = reinterpret_cast<int>(dataBuffer[5]);<br />
}<br />
Am I one the right track? I get an error on the reinterpret_cast. Suggestion?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
If you are receiving complete structure myMsg in BYTE array, then you can simply use:
memcpy(&myStuff, dataBuffer, sizeof(myStuff));
This will copy all bytes to structure memory, and you don't need explicit casting. Just be sure that byte order is intact over network
ARSALAN MALIK
|
|
|
|
|
Hi,
I have a dilaog box(parent) which has a tab control whose tabs are implemented as dialog boxes(children). Each tab has some controls say a button on tab1. I want to delegate the events cretaed by controls on various tabs to the parent dialog. How can i do that. Is there a macro just like reflection macros?
we know that control events will be handled by their parent that is my child dialog instead i want them to passed down the hierarchy to the parent dialog.
thanks
|
|
|
|
|
I know that this method can be used to calculate the height of a row of text based on it's point size:
int textheight = MulDiv(FontPointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72); But does anyone know how to calculate the total height of a line of text to included enough spacing between lines? I also need to know how to calculate the height of clipping rectangle required to fit a row of text including enough area for the tail of a "g" and the accents on somthing like this: "Ã". Is there an easy way to do this?
Joel Holdsworth
|
|
|
|
|
Aha I've found the answer in GetTextMetrics . Taken from mny old "Inside Visual C++" for MFC2 - published in 1993
Joel Holdsworth
|
|
|
|
|
::DrawText(..., ...|DT_CALCRECT)
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Can any one clarify this:
What is the advantage of overwriting a copy constructor when C++, by default, providing one.
Thanks,
Prudhvi.
|
|
|
|
|
Copy Constructor is used to solve the problem of Shallow copy when using dynamic data( as in pointers ). as the default copy constructor does a member wise copy of data members , this operation is undesirable while using pointers as both the pointer members point to the same area in memory . This can have undesired effects . By implementing a copy constructor , one can allocate new memory and make sure that space allocated is different .
In the case where memory management isnt required the default COPY cONSTRUCTOR will suffice .
Engineering is the effort !
|
|
|
|
|
also, remember to always implement a destructor that frees the new memory so that any class that is copied won't cause memory leaks.
[insert witty comment here]
bdiamond
|
|
|
|
|
|
Hi, Can any one help
How to identify a DLL whether it is a normal DLL or its a COM DLL, if no documentation is provided.
Thanks,
Prudhvi
|
|
|
|
|
Open the DLL inside the Dependency Walker utility (this utility ships with Visual C++ 6.0. If you don't have the utility it can be downloaded from http://www.dependencywalker.com/[^]). If the DLL in question is a COM server, the DLL will export the following functions:
DllCanUnloadNow
DllGetClassObject
DllRegisterServer
DllUnregisterServer
If these exported functions are not listed, then chances are it's not a COM server.
Hope this helps
-John
|
|
|
|
|
I m working on an MFC based MDI application . My view is of type CFormView and I currently have a CTreeCtrl as a component on the Form .
What I want to know is that when the app is executed a default document is opened , but is not sized proportional to the size of the mainframe . Same is the case for all new Documents opened . What is the right way of resizing the view ? Does the view do it based on the parent CFrameWnd or does the mainFrame handle this ?
Right now Im doing this in the View class to resize the view based on the MainWindow
void CMyView::OnSize(UINT nType, int cx, int cy) <br />
{<br />
if(init){ <br />
CRect r;<br />
this->GetParentFrame()->GetParent()->GetClientRect(&r);<br />
this->GetParentFrame()->MoveWindow(r);<br />
this->GetParentFrame()->GetClientRect(&r);<br />
m_tree.SetWindowPos(0,r.left+5,r.top+5,r.Width()/3-10,r.Height()-10,0);<br />
return ;<br />
} <br />
CFormView::OnSize(nType, cx, cy);<br />
}
void CMyView::OnInitialUpdate()<br />
{<br />
CFormView::OnInitialUpdate();<br />
<br />
init = true ; <br />
<br />
<br />
<br />
ResizeParentToFit();<br />
<br />
<br />
}
and this in the MainFrame :
void CMainFrame::OnSize(UINT nType, int cx, int cy) <br />
{<br />
CMDIFrameWnd::OnSize(nType, cx, cy);<br />
<br />
CRect r;<br />
this->GetClientRect(&r);<br />
CFrameWnd *wnd;<br />
wnd =this->GetActiveFrame();<br />
if(wnd){<br />
wnd->MoveWindow(r);<br />
}<br />
<br />
}
so that the view is resized when the mainFrame is moved .
I get a feeling there might be a better way to do this .
|
|
|
|
|
You're along the right lines, although I think all you need to do is go:
void CMyView::OnSize(UINT nType, int cx, int cy)
{
CRect clientrect;
GetClientRect(&clientrect);
m_Tree.MoveWindow(clientrect);
}
CFormView::OnSize(nType, cx, cy);
} You might want to overide OnEraseBkgrn and OnPain to reduce flicker.
However, I think you may be able to have an altogether better method by embedding the tree control directly as a control view using a CCtrlView , or even better: by using a CTreeView that way all the work is done for you!
Joel Holdsworth
|
|
|
|
|
I'm on my way out the door right now, so I didn't have a lot of chance to look at your code, but my CMainFrame wasn't getting sized correctly, so I send FALSE in ResizeParentToFit() to make sure the frame always accomodates my formview. Otherwise this call really doesn't do anything for formviews. Sending FALSE makes sure that the frame will always accommodate the form view's size.
[insert witty comment here]
bdiamond
|
|
|
|
|
We are in the proscess of designing a new multi platform game and require programers if you are interested please email Staff@kingszone.com
|
|
|
|
|