|
Cristiano G- wrote:
Have you got any other indication ?
Modify this:
void CChildFrame::AssertValid() const
{
CFrameWnd::AssertValid();
} Notice that you have to be aware when loosing some MFC assertion stuff.
You'll be in charge and have more responsability.
rechi
|
|
|
|
|
Please don't flame me if this is obvious. ! I'm a MFC beginner, but long time programmer in various languages. Now I have to get to grips with MFC and custom controls quite quickly, in fact I thought I was doing quite well.. Until now.
OK,
I have a Test program that used a CSliderCtrl control. In the testDlg.cpp file I had a OnHScroll() method that handles SB_THUMBTRACK etc messages to update a value and set a static control to that value.
Now, I've replaced the CSliderCtrl with a CVMRotaryFaderCtrl from:
http://www.codeproject.com/miscctrl/RotaryFaderMFC.asp
All compiles and runs fine. However as far as I can see the OnHScroll() method is no longer called.
Where do I start here? Is the CVMRotaryFaderCtrl not sending HScroll messages ?
Any clues on how I go about getting this to work ?
Many Thanks for any help
Andy C
andy@r2-dvd.org
|
|
|
|
|
I have an application where I have raw JPEG data in a memory buffer. I need to convert this to a raw image in memory and it needs to be pretty fast. I tried the IJG software, and it works for most images that I have, but I have a number of lossless JPEG images that it dies on. Specifically, it errors out because it encounters an SOF3 tag. I'm targeting Windows 2000/NT/XP for this.
My ideas:
1. Wrap my raw JPEG data into a COM class supporting IStream. Send the IStream to GDI+ to create an image. But then what do I do with the image??? I can't figure out how get the raw data out of it without saving it to another IStream as a BMP and then decoding the bitmap. This just seems like a lot of extra overhead and I'd like to find a better solution.
2. Use a codec to do this. However, I've not been able to find information on how to work with a codec.
3. Try to decipher the IJG software and handle/ignore the SOF3 tag.
Any other ideas? Anyone know how to use a codec or whether a codec could do this?
Thanks.
(Sorry if this post appears twice, I pushed submit and it made me login and I don't know if the first submit actually went through)
|
|
|
|
|
Keep idea 1 but use Bitmap (inherited from Image).
Bitmap has the method LockBits and UnlockBits to access/release the raw bit of the image.
Jonathan de Halleux, Belgium.
|
|
|
|
|
Thanks Jonathon,
I did this after getting your message. It works pretty well but, unfortunately, GDI+ also does not recognize the JPEG file that I'm using. Still, I'm going to stick with the GDI+ implementation. I can still read any lossy JPEGs that I've found, I just haven't been able to read the lossless JPEG files. I tested some competing products and they also could not read the lossless JPEGs, so I'm going to ignore the problem for the time being.
Thanks again, and here is the uncommented CPP file of the class I wrote:
#include "StdAfx.h"
#include "JPegDecoderGdiPlus.h"
#include "LImage.h" // my image class: contains my IMGFMT_* enumerations
using namespace Lorus::UImageProcessing;
JPegDecoderGdiPlus::JPegDecoderGdiPlus(void)
{
m_valid = false;
m_gdiPlusBitmap = NULL;
GdiplusStartupInput gdiplusStartupInput;
GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
}
JPegDecoderGdiPlus::~JPegDecoderGdiPlus(void)
{
m_valid = false;
delete m_gdiPlusBitmap;
GdiplusShutdown(m_gdiplusToken);
}
// LDataSource is the source of the raw image data. It has a method 'CreateStream' that
// creates an IStream* object. LDataSource is in my lowest-level library and is just a generic way
// for me to contain data that other objects can access.
bool JPegDecoderGdiPlus::InitializeDecode(LDataSource *imgSource)
{
m_valid = false;
if (!imgSource)
return false;
IStream *istrm = imgSource->CreateStream();
if (!istrm) return false;
m_gdiPlusBitmap = Bitmap::FromStream(istrm);
istrm->Release();
return true;
}
bool JPegDecoderGdiPlus::ReadHeader(void)
{
return true;
}
bool JPegDecoderGdiPlus::ReadScanLines(void *dst, ULONG dstStride)
{
if (!dst) return false;
if (!m_gdiPlusBitmap) return false;
int width = ImageWidth();
int height = ImageHeight();
int depth = PixelDepth();
if (width==0 || height==0) return false;
PixelFormat lockPixelFormat;
switch (GetImageFormat())
{
case IMGFMT_MONOCHROME1:
case IMGFMT_MONOCHROME2:
case IMGFMT_PALETTECOLOR:
if (depth == 8)
lockPixelFormat = PixelFormat8bppIndexed;
else
lockPixelFormat = PixelFormat16bppGrayScale;
break;
case IMGFMT_RGB:
case IMGFMT_HSV:
case IMGFMT_ARGB:
case IMGFMT_CMYK:
case IMGFMT_YBR_FULL:
case IMGFMT_YBR_FULL_422:
case IMGFMT_YBR_PARTIAL_422:
lockPixelFormat = PixelFormat32bppARGB;
break;
case IMGFMT_INVALID_OR_UNKNOWN:
default:
return false;
}
Rect rect(0, 0, width, height);
BitmapData bitmapData;
m_gdiPlusBitmap->LockBits(&rect, ImageLockModeRead, lockPixelFormat, &bitmapData);
UCHAR *sptr = (UCHAR*)bitmapData.Scan0;
UCHAR *dptr = (UCHAR*)dst;
ULONG bmapStride = bitmapData.Stride;
ULONG bytesToCopy = bmapStride;
if (bmapStride > dstStride) bytesToCopy = dstStride;
for (int yy=0 ; yy<height ;="" yy++)
="" {
="" ::memcpy(dptr,="" sptr,="" bytestocopy);
="" sptr="" +="bmapStride;
" dptr="" }
="" m_gdiplusbitmap-="">UnlockBits(&bitmapData);
return true;
}
bool JPegDecoderGdiPlus::AbortDecode(void)
{
m_valid = false;
FinishDecode();
return true;
}
bool JPegDecoderGdiPlus::FinishDecode(void)
{
delete m_gdiPlusBitmap;
m_gdiPlusBitmap = NULL;
return true;
}
int JPegDecoderGdiPlus::GetImageFormat(void)
{
// Lorus formats:
//IMGFMT_INVALID_OR_UNKNOWN,
//IMGFMT_MONOCHROME1,
//IMGFMT_MONOCHROME2,
//IMGFMT_PALETTECOLOR,
//IMGFMT_RGB,
//IMGFMT_HSV,
//IMGFMT_ARGB,
//IMGFMT_CMYK,
//IMGFMT_YBR_FULL,
//IMGFMT_YBR_FULL_422,
//IMGFMT_YBR_PARTIAL_422,
//return m_cinfo.out_color_space;
if (!m_gdiPlusBitmap) return IMGFMT_INVALID_OR_UNKNOWN;
UINT bmapFlags = m_gdiPlusBitmap->GetFlags();
if (bmapFlags & ImageFlagsColorSpaceGRAY)
return IMGFMT_MONOCHROME2;
if (bmapFlags & ImageFlagsColorSpaceRGB)
return IMGFMT_RGB;
if (bmapFlags & ImageFlagsColorSpaceCMYK)
return IMGFMT_CMYK;
if (bmapFlags & ImageFlagsColorSpaceYCBCR)
return IMGFMT_RGB;
return IMGFMT_INVALID_OR_UNKNOWN;
}
int JPegDecoderGdiPlus::ImageWidth(void)
{
if (!m_gdiPlusBitmap) return 0;
return m_gdiPlusBitmap->GetWidth();
}
int JPegDecoderGdiPlus::ImageHeight(void)
{
if (!m_gdiPlusBitmap) return 0;
return m_gdiPlusBitmap->GetHeight();
}
int JPegDecoderGdiPlus::PixelDepth(void)
{
if (!m_gdiPlusBitmap) return 0;
PixelFormat pixFormat = m_gdiPlusBitmap->GetPixelFormat();
switch (pixFormat)
{
case PixelFormat1bppIndexed:
return 1;
case PixelFormat4bppIndexed:
case PixelFormat8bppIndexed:
return 8;
case PixelFormat16bppGrayScale:
return 16;
case PixelFormat16bppARGB1555:
case PixelFormat16bppRGB555:
case PixelFormat16bppRGB565:
case PixelFormat24bppRGB:
case PixelFormat32bppARGB:
case PixelFormat32bppPARGB:
case PixelFormat32bppRGB:
case PixelFormat48bppRGB:
case PixelFormat64bppARGB:
case PixelFormat64bppPARGB:
return 32;
}
return 0;
}
int JPegDecoderGdiPlus::SamplesPerPixel(void)
{
if (!m_gdiPlusBitmap) return 0;
PixelFormat pixFormat = m_gdiPlusBitmap->GetPixelFormat();
switch (pixFormat)
{
case PixelFormat1bppIndexed:
return 1;
case PixelFormat4bppIndexed:
case PixelFormat8bppIndexed:
case PixelFormat16bppGrayScale:
return 1;
case PixelFormat16bppARGB1555:
case PixelFormat16bppRGB555:
case PixelFormat16bppRGB565:
case PixelFormat24bppRGB:
case PixelFormat32bppARGB:
case PixelFormat32bppPARGB:
case PixelFormat32bppRGB:
case PixelFormat48bppRGB:
case PixelFormat64bppARGB:
case PixelFormat64bppPARGB:
return 3;
}
return 0;
}
|
|
|
|
|
If you don't really need NT 4 support, perhaps you can use the DIB support for JPEG in Win2K/XP. Search MSDN for BI_JPEG.
--------
There are 10 types of people in this world. Those who know binary and those who don't.
|
|
|
|
|
In my application, have a EditBox and a WebBrowser2 control,I want to drop a select range's html source to the EditBox control,when I use WebBrowser2 control to navigate a Web page.
My original way is,when a event(mouse dorp) coming , I send a copy(Ctrl + C) event, then paste the content in the clipboard,but I think is effect on the other program. So I want other way for resolute this problem.
Very thanks.
|
|
|
|
|
Use the DOM to get a pointer to the IHTMLInputElement which represents your editbox. Then set the new value, and call reset() on the embedding Form to apply the new value.
Back to real work : D-24.
|
|
|
|
|
very thanks,Have you got other way? eg: I use IHTMLDocument2 interface,
call IHTMLDocument2::get_selection() get a IHTMLSelectionObject interface,
and call IHTMLSelectionObject::createRange() get IDispatch
then I didn't know how to get innerHTML From IDispatch.
my idea was born from a javascript function(document.selection.createRange().innerHTML)
|
|
|
|
|
Hello,
is there any way to show more than one line of text inside the listctrls cells?
I'm using the report view.
Thank you in advance.
|
|
|
|
|
You will have to do OwnerDraw.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Hi,
I am curious about OLBs and TLbs, when would you use a OLB over a TLb. Could anyone explain the difference, pros+cons etc.
Cheers
Rich
|
|
|
|
|
What is an OLB or a TLB ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
the .OLB extension name has been used in the past by MS along with Office, referring to their office object model. OLB stands for Object library, a way to refer to an automation-enabled object model.
the .TLB refers to a type-library, which is also an object library. But a .tlb is not necessarily automation-enabled.
Both are type libraries, generated by compiling IDL interfaces. To become automation-enabled, a type-library must expose dispatch interfaces.
A type-library is registered by its GUID in the registry (hkcr\typelib). So actually nobody really cares about the extension name you give it.
Sometimes, a type-library is even embedded in the COM server itself (as a .rc binary blob).
If that was only for the sake of semantics, you would use an .OLB extension name with automation-enabled object libraries (usable with VB, Perl, Python, ...). And you would use .TLB for all other object libraries.
VC7 doesn't change anything about it, except at design-time : you don't need an external IDL file anymore to declare type libraries.
Back to real work : D-24.
|
|
|
|
|
Is there a rule that you can not load images/cursors/bitmaps during the WM_CREATE message from the resource script.
I can load my icon from the resource file in dialog procedures, basically all other messages except WM_CREATE which is where I need it to place them on my button controls. They do load however when I use LoadCursorFromFile (for cursors)... The error code is 1813 (The specified resource type cannot be found in the image file)...Even though it does exists (Tested the same code in the WM_CTLCOLORLISTBOX message, odd place to put it I know but it was just a test, and it worked fine) This is annoying me greatly and if anyone has any feedback on this matter it would be much appreciated.
|
|
|
|
|
How does one clear all information in a list box?
Cheers
Ayush
|
|
|
|
|
SendMessage(hwnd, LB_RESETCONTENT, 0, 0);
hwnd = handle to the window (list box)
|
|
|
|
|
Hi!
The easier way to clear a listbox contents is to use the ResetContent function.
If your control member variable that represents your ListBox is m_lsXXX
then just write m_lsXXX.ResetContent();
I hope this helps
|
|
|
|
|
Hi,
In my SDI application I override menus to be ownerdrawn, and then draw them using OnDrawItem(...) of the main frame. However, i have this little problem: I click on the main menu, then a pop-up appears, I select a pop-up menu item, it displays a pop-up of next level. This second level menu partly overlaps the first one, and when it disappears the first menu doesn't get updated (part of the menu item which is selected has an unupdated trace on it). This doesn't happen with not ownerdrawn menu items.
Does anybody know what else should I do to provide all menu items get updated when necessary
Regards,
Vitaly
|
|
|
|
|
easy, only need to use 2 messages:
WM_MEASUREITEM and WM_DRAWITEM.
here is some code copied from my program, as a reference for u:
in WM_MEASUREITEM, call
void BMenuDraw::MeasureItem(int nIDCtl, MEASUREITEMSTRUCT *p)
{
NodeImage*pn=(NodeImage*)p->itemData;
ASSERT(pn!=0);
CString cs=pn->GetText();
HDC hdc=::GetDC(0);
CDC*pDC = CDC::FromHandle(hdc);
CSize size=pDC->GetTextExtent(cs);
p->itemWidth =size.cx+24;
p->itemHeight =22;
::ReleaseDC(0,hdc);
}
in WM_DRAWITEM, call:
void BMenuDraw::DrawItem(int nIDCtl, DRAWITEMSTRUCT *p)
{
CDC*pDC = CDC::FromHandle(p->hDC);
NodeImage*pn=(NodeImage*)p->itemData;
COLORREF clrBk =::GetSysColor(COLOR_MENU);
COLORREF clrTxt =::GetSysColor(COLOR_MENUTEXT);
COLORREF clrBkH =::GetSysColor(COLOR_HIGHLIGHT);
COLORREF clrTxtH =::GetSysColor(COLOR_HIGHLIGHTTEXT);
CString cs;
if(p->itemAction==ODA_DRAWENTIRE)
{
P_DrawItem(pDC,pn,p->rcItem,p->itemState,clrBk,clrTxt);
}
if(p->itemState&ODS_SELECTED)
{
if(p->itemAction&(ODA_SELECT|ODA_DRAWENTIRE))
{
P_DrawItem(pDC,pn,p->rcItem,p->itemState,clrBkH,clrTxtH);
}
}
else
{
if(p->itemAction&ODA_SELECT)
{
P_DrawItem(pDC,pn,p->rcItem,p->itemState,clrBk,clrTxt);
}
}
}
void BMenuDraw::P_DrawItem(CDC *pDC, NodeImage *pn, const CRect &rcItem, int iState, const COLORREF clrBk, const COLORREF clrTxt)
{
BOOL bDis=(iState&ODS_DISABLED)?1 ;
BOOL bChk=(iState&ODS_CHECKED)?1 ;
BOOL bSel=(iState&ODS_SELECTED)?1 ;
BImageHold*pHold=image.GetMenuHolder();
const int iBmpWH=pHold->iBmpWH;
int iBkMode=pDC->SetBkMode(TRANSPARENT);
int iX=rcItem.left+3;
int iY=rcItem.top+2;
CRect rcTxt =rcItem;
rcTxt.left =iX+24;
rcTxt.top +=2;
pDC->FillRect(&rcTxt,&CBrush(clrBk));
CDC dc; dc.CreateCompatibleDC(pDC);
CBitmap*pBmpOld;
if(bDis) pBmpOld=dc.SelectObject(&pHold->bmpD);
else
if(bChk) pBmpOld=dc.SelectObject(&image.bmpS);
else pBmpOld=dc.SelectObject(&pHold->bmpN);
pDC->BitBlt(iX,iY,iBmpWH,iBmpWH,&dc,pn->iPos*iBmpWH,0,SRCCOPY);
CString cs=pn->GetText();
COLORREF clrTxtOld;
if(bDis)
{
BYTE iClr=223;
clrTxtOld=pDC->SetTextColor(RGB(iClr,iClr,iClr));
rcTxt.top++;
rcTxt.left++;
if(!bSel) pDC->DrawText(cs,&rcTxt,DT_EXPANDTABS);
rcTxt.top--;
rcTxt.left--;
COLORREF clrTxtDis=::GetSysColor(COLOR_GRAYTEXT);
pDC->SetTextColor(clrTxtDis);
pDC->DrawText(cs,&rcTxt,DT_EXPANDTABS);
}
else
if(bChk)
{
BYTE iClr=223;
clrTxtOld=pDC->SetTextColor(RGB(iClr,iClr,iClr));
rcTxt.top--;
rcTxt.left--;
if(!bSel) pDC->DrawText(cs,&rcTxt,DT_EXPANDTABS);
rcTxt.top++;
rcTxt.left++;
pDC->SetTextColor(clrTxt);
pDC->DrawText(cs,&rcTxt,DT_EXPANDTABS);
}
else
{
clrTxtOld=pDC->SetTextColor(clrTxt);
pDC->DrawText(cs,&rcTxt,DT_EXPANDTABS);
}
dc.SelectObject(pBmpOld);
pDC->SetBkMode(iBkMode);
pDC->SetTextColor(clrTxtOld);
}
in code above, i used menu image (NodeImage), u just modify it a little, must be well.
includeh10
|
|
|
|
|
hi everyone,
I read the article "Printing Made Easy with MFC" and am using the GPrintUnit and GPrintJob classes.
I would like to know how to redefine the Rect for printing, or more specifically how to introduce a margin so that my printing does not start on the edge of the page.
Thanks in advance
Regards
Rui
|
|
|
|
|
|
Thanks for the article, it does explain quite a bit on printing.
But I was wondering more about where to set the JRECT defined in the classes GPrintUnit and GPrintJob?
Although I am going to try to override the GPrintInfo function and set the JRECT there. I am not sure if this is correct.
Thanks
Rui
|
|
|
|
|
hi,
I defined a message in *.exe. And in *.dll, I trigered the message, nothing happened. tell me why.
Note, this message works well in *.exe
Thanks in advance
Extreme programming. Do the No.1
|
|
|
|
|
Did you add a command handler for that message?
Best regards,
Alexandru Savescu
|
|
|
|
|