|
No, as far as I know there is not a function like that. What you can do is use SendDlgItemMessage or SendMessage to send a STM_SETICON message to a Bitmap or Icon control.
HICON LoadImage(hInstance,MAKEINTRESOURCE(IDI_ICON1),IMAGE_ICON,GetSystemMetrics(SM_CXICON),GetSystemMetrics(SM_CXICON),0);
SendDlgItemMessage(hDlg,IDC_STATIC1,STM_SETICON,(WPARAM)(HICON)Icon,0); Hope that helps
P.S. if you use a bitmap, change the Icon stuff to Bitmap and the dementions to the height and width of the bitmap. check out the LoadImage function on MSDN for more information
wWw.KruncherInc.cOm - My cool programs
|
|
|
|
|
No! You can use a picture control to display an image in a dialog, it may have a message that allows you to change the picture/bitmap it contains; otherwize you may need to draw it youself via the OnPaint method/function of your CDialog derive class. Take a look at the "Dialog and Windows" section of codeproject, it may be of help.
Good Luck!
INTP
|
|
|
|
|
Why do alot of C++ programmers (mostly MFC) use the TEXT macro (or function?)?
MessageBox(0,TEXT("Message"),TEXT("Title"),0); when you can just do:
MessageBox(0,"Message","Title",0);
Also do you need to specify the type, like this:
MessageBox((HWND)0,(LPSTR)"Message",(LPSTR)"Title",(UNIT)0);
wWw.KruncherInc.cOm - My cool programs
|
|
|
|
|
if you building under _UNICODE then this statement
KingKruncher wrote:
MessageBox(0,"Message","Title",0);
would fail.
but
KingKruncher wrote:
MessageBox(0,TEXT("Message"),TEXT("Title"),0);
this will work.
|
|
|
|
|
It has nothing to do with MFC. If u want ur MFC/API program to be portable and compatible with systems that use UNICODE representation of characters, then use the TEXT MACRO before all strings.
...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
It is pretty simple!
"Message" is ASCII single byte code.
L"Message" is double byte code.
If you might want to compile your code, using the MS SDK, for UNICODE (native to NT/2000 and above - not 95/98/Me) then you should use the macros _T() or TEXT(). What those macros do or do not do is add the 'L' in front of the string, based on whether you are creating an ASCII standard version of your program or a UNICODE version of you program.
It's that simple. As a general rule use the _T() or TEXT() for you text string when programming for windows, but stay alert for function that take arguments like LPSTR or LPCSTR, because they can not handle UNICODE strings. Functions that take arguments like LPTSTR and LPCTSTR are UNICODE compatible.
INTP
|
|
|
|
|
I have successfully utilized a 3rd party activex control w/VB6, however, I would like to rewrite the program in Visual C++ for several reasons, one of which is to have it run from the commandline. The ActiveX control is registered on my system, but I really have no idea where to start.... Is this possible, and if so, what would be my best strategy?
Any help is appreciated...
|
|
|
|
|
I have a VC++ MFC AppWizard exe project,and I have add these two classes to the project:
class CRightView : public CFormView
class CImageView : public CView
In the Right View class I have a button. In the ImageView class I have nothing.
I redefined the CMainFrame::OnCreateClient method,adding:
m_wndSplitter.CreateStatic(this,1,2); m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CImageView),CSize(0,0),pContext);
m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CRightView),CSize(0,0),pContext);
Now I can't manage to "communicate" between both frames. I can see in the result window both frames,and the button in the RightView frame, but when I push that button,even a simple "void CRightView::OnOK() {AfxMessageBox("HI");}" is not working, and nothing shows up. What's wrong here?
Thanks.
|
|
|
|
|
I know there is software that can create
animated GIFS. How hard is it to put together
a program that can make an animated GIF? Does
sample code exist anywhere on codeproject?
It doesnt seem that hard taking a handful of
GIF files and just making one show, then the
next, then the next, until there all done.
Presto you got an animation program. What
concerns me is bringing them together and
making them into a new GIF. That I don't
know.
Any input is helpful.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
if u read the gif format spec document u can find out how to write multiple images into one file and set the animation variables reqd to make it an "animated" gif
and ur right ... its not really hard to do it on a basic level
"there is no spoon" biz stuff about me
|
|
|
|
|
How can I retrieving a image format ie CF_BITMAP from Clipboard in VC++ and write it to bmp of jpeg file
Jack
|
|
|
|
|
How can I retrieving a image format ie CF_BITMAP from Clipboard in VC++ and write it to bmp or jpeg file
Jack
|
|
|
|
|
|
I have the following code in a preferences dialog in an MFC app, which isn't always called, and looks like this:
PIP_ADAPTER_INFO pAdapterInfo;
PIP_ADAPTER_INFO pAdapter =NULL;
DWORD dwReturn =0;
pAdapterInfo=(IP_ADAPTER_INFO*)malloc(sizeof(IP_ADAPTER_INFO));
ULONG ulOutLen=sizeof(IP_ADAPTER_INFO);
if(GetAdaptersInfo(pAdapterInfo,&ulOutLen)==ERROR_BUFFER_OVERFLOW)
{
GlobalFree(pAdapterInfo);
pAdapterInfo=(IP_ADAPTER_INFO*)malloc(sizeof(ulOutLen));
}
if((dwReturn=GetAdaptersInfo(pAdapterInfo,&ulOutLen))==NO_ERROR)
{
pAdapter=pAdapterInfo;
while(pAdapter)
{
pAdapter=pAdapter->Next;
}
}
The first time I run the executable after compile, I get this error:
The exception Integer division by zero.
(0xc0000094) occurred in the application at location 0x0040124d
Everything after that I run the same executable, the program runs fine, and the code in question works fine. But when I close the app, I get this error about three times:
The instruction at "0xSOMEADDRESs" referenced memory at "0x00000000". The memory could not be "read".
I've tried commenting out various bits of the code to see which line causes the problem, but I can't find anything consist.
Any idea what's wrong or what I could do?
Thanks,
Aaron Stubbendieck
modified 12-Jul-20 21:01pm.
|
|
|
|
|
Are you using a property page dialog for the preferences ? If so, one of the exceptions is explained by that: when a property page is loaded by a property sheet object, an exception is raised. This functionality is discussed in the property sheet class.
Next, have you tried stepping though the code ? What point is it exactly that causes the exception "Division by zero" ?
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Currently I'm just using a CDialog derived class with some controls on it, though I may switch to property pages in the future.
I ran it through the debugger, and when I go to my options dialog (which requires me to hit alt after selecting it from the menu for some reason) and click the button (for testing purposes) that calls that piece of code, it works perfectly with no errors or anything. When I exit the application, I don't get any popup access violations, but there are some listed in the debug output window, and they're all in kernel32.dll and at the same memory address.
I have no idea what to do. Suggestions?
Thanks,
Aaron Stubbendieck
modified 12-Jul-20 21:01pm.
|
|
|
|
|
im doing a find dialog, here's my code
void CWordFind::OnButtonFindNow()
{
// TODO: Add your control notification handler code here
// update from screen to var
UpdateData(TRUE);
LVFINDINFO info;
int nIndex;
info.flags = LVFI_STRING;
info.psz = m_sFindWord;
if ((nIndex = m_pParent->m_ListCtrl.FindItem(&info)) == -1)
{
MessageBox("Word was not found.", "Find");
}
else
// highlight row nIndex
}
how can i highlight the row in CListCtrl?
the only thing that comes close as a member function is SetSelecteionMark, but it's not used for highlighting, i supposed..
thanks for your help
|
|
|
|
|
you need to take own draw over list control and set different background (font, frame, whatever) for item you like to highlite.
Yours, Katerina
|
|
|
|
|
any sample code for that? sorry im new at this
|
|
|
|
|
i think it is in MSDN or somewhere here, try to search
|
|
|
|
|
thanks, found a great one here..thanks again
|
|
|
|
|
If you want to select the item like you would do with the mouse, but you want to do it programmatically, this should do it:
if ((nIndex = m_pParent->m_ListCtrl.FindItem(&info)) == -1)
{
MessageBox("Word was not found.", "Find");
}
else
{
m_ListCtrl.SetItemState( nIndex, LVIS_SELECTED, LVIS_SELECTED );
m_ListCtrl.SetSelectionMark( nIndex );
}
Good luck,
Chris Richardson
|
|
|
|
|
hi,i'm studying Security issue,and i add the code in my prog:
#include "accctrl.h"
#include "aclapi.h"
...........................
CSecurityDescriptor sd;
sd.InitializeFromThreadToken();
hr = CoInitializeSecurity(sd, -1, NULL, NULL,
RPC_C_AUTHN_LEVEL_PKT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL);
_ASSERTE(SUCCEEDED(hr));
but the prog compiled show:
C:\CommuServ.0411(wnd.err)\CommuServ.cpp(83) : error C2065: 'CSecurityDescriptor' : undeclared identifier
what is wrong?
appreciate any help!!
|
|
|
|
|
did you added the correct header corresponding to your CSecurityDescriptor (like SecurityDescriptor.h) ?
TOXCCT >>> GEII power
|
|
|
|
|
Hi,
I'm looking for some code that understands mathematical expressions presented as a string (e.g. "y=sin(x)+2x").
Have you seen any code that does this? This code seems so fundamental to me, it could even be provided within MFC but I can't find it.
I'm writing an MFC application that will plot a x-y graph of a mathematical equation.
So ideally code I am looking for will accept a string input (e.g. "y=x^2+5") and an x value will output the corresponding y value.
Thank you
Shan
|
|
|
|
|