|
Is it possible to change the bitmap used by a button in the toolbar? I've had a look and it seems the Toolbar bitmap is made out of each of the button bitmaps, but I can't see how to change it during run time for an individual button.
Am I being stupid? Thanks for any help.
Cheers,
Ali
|
|
|
|
|
Use CToolBar::LoadBitmap() to load the toolbar bitmap and CToolBar::SetButtonInfo() to set index in the toolbar bitmap, which points to desired image.
Robert-Antonio
Love, truth and electric traction must gain victory over hate, lie
and diesel traction.
|
|
|
|
|
Thank you for taking the time to help me - at least now I've got a starting point .
I've looked at SetButtonInfo() and that seems to be the right direction to go in. I added it to the OnUpdate handler for the button like this:-
void CMainFrame::OnUpdateButtonModLevel(CCmdUI* pCmdUI) <br />
{<br />
UNREFERENCED_PARAMETER(pCmdUI);<br />
m_wndToolBar.SetButtonInfo(9, ID_BUTTON_MOD_LEVEL, TBBS_BUTTON, IDB_BITMAP_DOWN_ARROW );<br />
<br />
}
I'm definitely on the right lines because now the button is blank!
I think it maybe the last parameter that I've got wrong, the help says "New index for the button’s image within the bitmap." What I've put in is the ID of the bitmap.
Or perhaps I've put the code in the wrong place.
I'll keep trying, any ideas appreciated.
Thanks again.
Ali
|
|
|
|
|
u put the index of the image within the imagelist ... i guess if its a single image image list then use 0
"there is no spoon" biz stuff about me
|
|
|
|
|
I know the use of ShellExecuteEx to show the properties of one item.
It is all nice and handy but what about selecting and showing the properties of multiple files as in windows explorer?
The SHELLEXECUTEINFO lpFile field can only accept one path and I could not find anything about multiple files with ShellExecuteEx in MS documentation.
please help if you have any idea.
Thanks.
avivhal
|
|
|
|
|
I'm trying to create a push button such that when it's clicked on the text on the button changes and the button is depressed. If the button is clicked on again then it gets back to its original state.
Here's the code that I've written:
if(BM_CLICK)
{
//if button depressed return to original state
if(SendMessage(hwnd[ID_BUTTON_START], BM_GETSTATE, 0, 0) == BST_PUSHED)
{
SendMessage(hwnd[ID_BUTTON_START], BM_SETSTATE, 0, 0);
SetWindowText(hwnd[ID_BUTTON_START], TEXT("start"));
}
//else depress button and change button text
else
{
SendMessage(hwnd[ID_BUTTON_START], BM_SETSTATE,1 , 0);
SetWindowText(hwnd[ID_BUTTON_START], TEXT("Pause"));
}
}
My problem is that I can't get the button to get to it's original state. What am I doing wrong here?
|
|
|
|
|
Hi,
Take a CheckBox and set under the properties the 'Push-like' style and try:
void CMyProject::OnMyCheckBox()<br />
{<br />
m_bPushed = !m_bPushed;<br />
if(m_bPushed)<br />
GetDlgItem(IDC_CHECK_BTN)->SetWindowText(_T("Pause"));<br />
else<br />
GetDlgItem(IDC_CHECK_BTN)->SetWindowText(_T("Start"));<br />
}
Hope its helpful
P.
|
|
|
|
|
Thanks for the reply. I got it to work
|
|
|
|
|
I have a rtf editor in a dialog based app and while somebody seaches on the net and copy the information needed he wants not to switch between apps and not to press Ctrl+V , but when he selects and copy he wants the text to be pasted into my rtf editor. I did this but the text is pasted over and over and over again. How can I paste the text, img, text+img just one single time?
When I copy from other app than IE the text is pasted one single time but when I copy from IE the text is pasted over and over again.
The code is the following:
void CMyRtfDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
if ( nIDEvent < 900)
{
COleDataObject oleTarget;
oleTarget.AttachClipboard ();
if(oleTarget.IsDataAvailable(CF_TEXT) || oleTarget.IsDataAvailable(cfRTF))
{
if ( MyChangeClip() )
{
PasteText ();
UpdateData();
InsLineBreak();
}
}
CDialog::OnTimer(nIDEvent);
}
bool CMyRtfDlg::MyChangeClip()
{
int nValue;
bool bContent;
// Test to see if we can open the clipboard first.
if (OpenClipboard())
{
// Retrieve the Clipboard data (specifying that
// we want ANSI text (via the CF_TEXT value).
HANDLE hClipboardData = GetClipboardData(CF_TEXT | cfRTF);
// Call GlobalLock so that to retrieve a pointer
// to the data associated with the handle returned
// from GetClipboardData.
char *pchData = (char*)GlobalLock(hClipboardData);
// Set a local CString variable to the data
// and then update the dialog with the Clipboard data
strFromClipboard = pchData;
// Unlock the global memory.
GlobalUnlock(hClipboardData);
// Finally, when finished I simply close the Clipboard
// which has the effect of unlocking it so that other
// applications can examine or modify its contents.
CloseClipboard();
}//end open clipboard
else
{
AfxMessageBox("Can't open the clipboard!!!");
//return true;
}
// -1 if the substring or character is not found
// this means that clipboard content has changed
m_rtf.GetWindowText(m_strFromRtf);
//AfxMessageBox(m_strFromRtf);
nValue = m_strFromRtf.Find(strFromClipboard);
if ( nValue == -1 )
bContent=true;
else
bContent=false;
return bContent;
}
nValue is always -1 when I paste from IE.Can anyone tell me why?
And other question : How can I paste img from Word?
Thank you,
Adriana
|
|
|
|
|
Hello,
I am a beginner in the world of Embedded VC++ programming and am confronted with the following problem:
I have a PDA (iPAQ, Win CE OS) connected to my Laptop. I have to implement a program such that i can write data to the COM port which the PDA has to read and display.Now, I can write seperate read and write programs, but how can I run it simultaneously?Moreover, if the port is open for writing by one program can I open it for reading by another program at the same time?Any pointers in clearing the above queries is most welcome.
Thanks a lot for your time,
Deepa.
|
|
|
|
|
Deepa Gopal wrote:
if the port is open for writing by one program can I open it for reading by another program at the same time?
From my undestanding, since the two programs are running on different machines (laptop and PDA), you just have to make sure both sides have opened the same port using the same settings (e.g. Parity, Flow Control..etc). Have the PDA continously reading any incoming data (ReaadFile()) and the laptop to send the data whenever you like.
Hope it helps in some way.
|
|
|
|
|
hi everyone,
I have a question here and need your help.
I'am writing an program to capture screen real time and by which to generate avi video.
My problem is that I want to get the size of the avi file while writing new frames into it, in order that the user can have an clear idea about how the process is going (the current size of the avi file).
Since the avi file is being opened and written that I can not get a handle to the avi file by "CreateFile" and use it in "GetFileSize".
I think maybe I should calculate the approximate avi file size by "frame size * frame number". But because the avi file maybe in compressed format that I don't know how to decide the size of a frame.
Moreover, if one particular frame is being repeated 100 times in the avi file should I count it for one time or for 100 times ?
Anyway, any information about calculate avi file size while creating it is appreciated.
Thanking you in advance.
------------------
Memory either forgets things when you don't want it to, or remembers things long after they're better forgotten.
|
|
|
|
|
I found no replys to my question.
But I wish that there are somebody that can help me.
Thanks for your reading.
------------------
Memory either forgets things when you don't want it to, or remembers things long after they're better forgotten.
|
|
|
|
|
This is a tough one. I don't know quite how to ask it, nor even which forum to post it. So, here goes.
I'm working on a plug-in for an application called DesktopSidebar, a side panel that sorta emulates the Longhorn sidepanel. Anyway, in the SDK for developing plugins there is a C++ DLL sample, as well as a C# one because the application allows all .NET languages as well as standard C++ through COM Interop... so the plugins could even be done in VB.NET. At any rate, 99% of it works fine for me, except for when I specify the icon that's used in the "Add Plugin" dialog. In the C++ example the code is such:
char szPath[_MAX_PATH];
GetModuleFileName(_AtlBaseModule.GetResourceInstance(),szPath,sizeof(szPath));
std::stringstream panelIcon;
panelIcon<<szpath<<","<<idb_icons<<",0";
csidebar="" sidebar(psidebar);
="" sidebar.registerpanel(
="" "recyclebinpanel",
="" "recyclebin",=""
="" "recyclebin_desc",
="" panelicon.str(),
="" "system_cat",
="" ",254,4",
="" "",
="" plugincookie);
the="" resource="" in="" question,="" idb_icons="" (id="" is="" 100)="" a="" bitmap="" added="" to="" the="" project="" and="" resulting="" string="" for="" icon="" this="" case="" (at="" panelicon.str())="" "<path="">\DLLNAME.dll,100,0" I guess the main application can use that to query resource ID 100 (and maybe 0 is an offset or something.... because the bitmap contains 2 images side by side).
How in the world can you accomplish this is either VB.NET or C#? In both languages you can "embed" a resource by adding the bitmap to the project and changing it to "Embedded Resource". However, there is no indication of any sort of ID. I did quite a bit of digging and using Ildasm.exe I was able to look at my DLL and get the following:
.mresource /*28000002*/ public dsshutdown.icons.bmp
So, there's my embedded resource with an "ID" presumably of 28000002. However, using the same calling convention in my component as above, doesn't work at all... well I see a black blob. Also, if I use Resource Grabber and look at the C++ example built DLL it easily pulls the bitmap from the DLL. Using Resource Grabber on my DLL, however, doesn't show any bitmap at all even though it's clearly there. I know how to write code within .NET to pull out and use the resource. However, the call to "RegisterPanel" above wants a string.
Is there some other way to go about this? ... some way to put the image into my DLL in the same method as in C++ to make the application able to render my bitmap icon?
Thanks.
|
|
|
|
|
Hi guys,
When the application is minimized it takes a low prority, i found out this when i process a file in MDI application,The file that is processed in 20 secs when the application is not minimized, takes 1 min to process when the application is minimized. How shd i set high priority to my MDI application always.Is it safe to do this?,Will this affect the other system applications?, please explain.
Thanks
Krithika
|
|
|
|
|
Hi,
table containing two fields one is code and another is name. i need to fetch repeated names only.(more than one occurance of name and code is not same). any one help to me. thanks in advance.
Have A Nice Day!
Murali.M
Have A Nice Day!
Murali.M
|
|
|
|
|
try this
SELECT DISTINCT t1.code, t1.name
FROM mytable t1 INNER JOIN mytable t2
ON t1.name = t2.name
WHERE t1.code <> t2.code
ORDER BY t1.code
|
|
|
|
|
Is it possible to have an edit control wrap the text so that you don't have to press return in order to go to the next line? If so how?
Thanks.
- monrobot13
|
|
|
|
|
Hi
Set the properties of the edit box so that
Auto HScroll = false
Multiline = true
Paul Hooper
If you spend your whole life looking over your shoulder, they will get you from the front instead.
|
|
|
|
|
Thanks for the reply. I'll try that out.
- monrobot13
|
|
|
|
|
EDIT: I Solved my own problem
I moved my button-logic to the MainFrm.cpp class, and used the GetPane() function to access the correct pane. I guess the best solutions are the ones you come up with yourself.
********************************************************************************************
Original Post Below:
I've read a number of posts here about communicating when using splitters, but I'm still having a problem, so I'd appreciate any help. I have an SDI application with a toolbar and three views ... one of which is a CHtmlView derived view. I'm trying to control the web browser control using the toolbar buttons.
Here's what I have:
-------------------
I have a pointer to the MainFrm object in my MyApp.cpp (defined MyApp.h).
In my MainFrm.cpp, I'm using the RUNTIME_CLASS(CClassType) macro to create each of the three splitter panes, and I'm saving pointers to each views.
In MyApp.cpp, I have a message handler for the user clicking the "Back" button:
void CMyApp::OnBack(){
CMainFrame* p_localMainFrameRef = (CMainFrame*) p_viewMain;
CMyAppHTMLView* p_localWebFrameRef = (CMyAppHTMLView*)(p_localMainFrameRef->p_viewWeb);
p_localWebFrameRef->GoHome();
}
I'm getting the following error when I click the "Back" button:
Unhandled exception at 0x7c1a8130 (mfc71d.dll) in YourApplication.exe: 0xC0000005: Access violation reading location 0x00003972.
Can anyone lend some advice as to what I'm doing wrong ... or suggest a better approach to allowing me to communicate between frames, and with the toolbar?
Thanks very much,
telstar
|
|
|
|
|
Need to grey out the background of a ClistBox on pressing button grey on a dialog. The list can contain items which should also be greyed out and on pressing button enable list the list should be enabled with all its items
using wm_ctlcolor message with appropriate brush works, but when the list has items the portion with those items are white while rest is grey.
|
|
|
|
|
You have to enable the transparent background mode for the DC in the WM_CTLCOLOR method BEFORE returning the new brush:
HBRUSH CSampleDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
pDC->SetBkMode(TRANSPARENT);
if (pWnd->GetDlgCtrlID() == IDC_MYLISTBOX)
{
if(m_bGrayed)
return (HBRUSH)GetStockObject(GRAY_BRUSH);
else
return (HBRUSH)GetStockObject(WHITE_BRUSH);
}
return hbr;
}
Regards, mYkel
|
|
|
|
|
How can i use a DLL to link 2 different Static Lib in Visual C++ 6.0?
I need help URGENTLY!!!
Thank you very much...
|
|
|
|
|
As an advice if you have more than one dll loaded in ur application then you need to consider rebasing ur dll.
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|