|
It's Visual Studio 97. (Yikes! I know...)
The one article I referenced from 2000 was by a guy who sounded like a pretty experienced programmer, and he also discovered that programmatically selecting items in a virtual list control didn't seem to work. He never found any solution other than the fake mouse click. It sounded like he did get it to work for the initial selection as well. Unfortunately his code isn't out there any more so I can't see where he did that! (I don't know what version he was using, but his article was from 2000)
If I make the list box non-virtual, I can programmatically select items fine at any time. But as soon as I make it virtual, I can't programmatically select at all.
|
|
|
|
|
AmVal wrote: It's Visual Studio 97. (Yikes! I know...)
I'm worried MFC had its own version of the control then.
I just can't remember
These days (since Windows 98), the control is provided by
the operating system. You may want to not use MFC for the
control and use Win32 APIs directly. The problem seems to be
in MFC, not in the control.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
You're right, if I just use:
ListView_SetItemState(MyList_, i, LVIS_SELECTED, LVIS_SELECTED)
It works to select the first item on initial display, as well to select at any other time. So I can avoid the fake mouse clicks! Yeah!
Thanks so much Mark!
|
|
|
|
|
Cool! Thanks for the update
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
You can also do this:
//GotoDlgCtrl(&MyList_);
MyList_.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
GotoDlgCtrl(&MyEdit_); // optional - if you want initial focus on the edit control
It seems you can't set LVIS_FOCUSED unless the control has focus.
And if the control doesn't have focus and you try to specify LVIS_SELECTED | LVIS_FOCUSED,
it doesn't set either state
Good to know!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I'm not expert on exceptions. I need to catch some memory exception and ignore it, but it des not work. It only works in debug release (exception is ignored), but in release mode it crashes like when I don't handle the exception. What is the problem?
Here is code :
try
{
*((char*)0)=1;
}
catch(...)
{
}
It is MFC app in VC6.0.
Thank you.
|
|
|
|
|
This is the difference between C++ typed exceptions and Win32 structured exceptions. What you have is the former. See _set_se_translator() for more.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Thank you. I'm going to check it.
I wonder why debug mode caught the exception. Does debug mode use some default translator?
|
|
|
|
|
rrrado wrote: I wonder why debug mode caught the exception.
I'm really not sure, but it may have to do with the optimizer.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
rrrado wrote: I wonder why debug mode caught the exception
Might be because you set the "Enable C++ Exception=> YES with Structured exception (/EHa)" for debug configuration settings but not for release configuration.
|
|
|
|
|
In C++ - assuming the implementation follows the standard - catch is only allowed to catch exceptions raised using the throw keyword: since this isn't the case in your example the code in the catch block should NOT be executed. MSVC6 got this wrong but the bug has been corrected in later versions. The /EH[^] switch can be used to reinstate the bug.
Steve
|
|
|
|
|
|
Hi all...
I'm using CxImage to load and draw PNG. Either in dialog box or preferably on desktop screen.. Need help how to draw the PNG. So far i did this.
CxImage* newImage = new CxImage();
newImage->LoadResource(FindResource(NULL,MAKEINTRESOURCE(IDR_PNG1),"PNG"),CXIMAGE_FORMAT_PNG);
Thanks.
|
|
|
|
|
For PNG files you can use of CImage class and its easy to use.
|
|
|
|
|
I guess Cimage and CxImage are sort of same thing..
Neverthless how can i do with Cimage Class..
Thanks..
|
|
|
|
|
Surely CxImage must have rendering methods.
Look for methods called Draw()
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark...
After i call this.
newImage->LoadResource(FindResource(NULL,MAKEINTRESOURCE(IDR_PNG1),"PNG"),CXIMAGE_FORMAT_PNG);
How do i call Draw??
Draw has these two declaration..
long Draw(HDC hdc, long x=0, long y=0, long cx = -1, long cy = -1, RECT* pClipRect = 0, bool bSmooth = false);
long Draw(HDC hdc, const RECT& rect, RECT* pClipRect=NULL, bool bSmooth = false);
Thanks..
|
|
|
|
|
Till now i've done this with no success.. Trying to draw PNG on desktop.
HBITMAP m_bitmap = NULL;
CxImage image("E:\\My_Prog\\FINAL_PNG\\Res\\eScan.png", CXIMAGE_FORMAT_PNG);
HWND hDesktop = GetDesktopWindow();
HDC hdc = GetDC(hDesktop);
m_bitmap = image.MakeBitmap(hdc);
image.Draw(hdc);
Where am i wrong?
|
|
|
|
|
Edited..
Now i'm doing something like this.. This should disply PNG on picture control..But no success..
case WM_INITDIALOG:
{
HBITMAP m_bitmap = NULL;
CxImage image("E:\\My_Prog\\FINAL_PNG\\Res\\eScan.png", CXIMAGE_FORMAT_PNG);
RECT rect;
HWND hImage = GetDlgItem(hWnd, IDC_DRAW_IMAGE);
GetClientRect(hImage, &rect);
int rectHeight = rect.bottom - rect.top;
int rectWidth = rect.right - rect.left;
int height = image.GetHeight();
int width = image.GetWidth();
int xpos = 0;
int ypos = 0;
if(height > rectHeight || width > rectWidth)
{
double ratiox = (double)rectWidth /(double)width;
double ratioy = (double)rectHeight/(double)height;
double ratio = ratiox > ratioy? ratioy: ratiox;
width = width * ratio;
height = height * ratio;
image.Resample(width, height);
image.Save("E:\\My_Prog\\FINAL_PNG\\Res\\eScan.bmp", CXIMAGE_FORMAT_BMP);
}
xpos = (rectWidth - width)/2;
ypos = (rectHeight - height)/2;
HDC hdc = GetDC(hImage);
image.Draw(hdc, xpos, ypos);
break;
}
|
|
|
|
|
You don't draw on "picture controls". Picture controls keep their own
bitmap and render it themselves.
Try getting your image to render on the window first, then maybe work
on rendering on a child window.
This isn't a CxImage support site, and I've never used the library,
nor am I going to research the documentation, so it's tough to figure
out what's not working.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
There is, as you probably know, the CxImage article, here [^] at CodeProject . On the web there is also the library documentation page [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Like this:
CImage m_Image;
m_Image.Load(_T("yourfile");
m_Image.BitBlt(hdc,0,0);
|
|
|
|
|
Hi all
I am getting an error message in my application "This application has failed to start because cximagecrtd.dll was not found".
I tried to download the cximagecrt.dll/cximagecrtd.dll from net. But i couldn't able to find anywhere. Can some one please provide this for me.
Thanks in advance.
Regards,
Balaram.
Regards,
balaram
|
|
|
|
|
Hi all,
In my mfc application I have a main window which has no title bar, no resizing frame, no border n all. I am programmatically creating title bar and maximize and minimize buttons.
For resizing and move operations I am handling hit test messages.
But since I have no title bar so system menu doesn’t appear by default, and also left click on task bar doesn’t maximize the window.
For this to work I added WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU styles to my frame window. Everthing started working sysmenu on right click,maximize,minimize,move n all but unexpectedly resizeing stopped working. If I remove WS_SYSMENU resize starts working. I have no idea what happened. One solution thought was to add WS_THICKFRAME to the window but I don’t want to use it as it changes the look of window which client doesn’t want.
Can you suggest something on this?
|
|
|
|
|
Hi All
How can i convert String to ascii?I have a file type txt and i want to write string in form of asci.So plz help me
|
|
|
|