|
I use a CRectTracker on my WM_LBUTTONDOWN callback, and it's working ok, but the problem is that it eats my WM_LBUTTONUP, which I need to do additional processing.
Is it kosher to call PostMessage(hwnd, WM_LBUTTONUP ) at the end of the bottom down callback ? Or is there another way ? I've tried it, and luckilly, it works, I only receive one WM_LBUTTONUP, but it doesn't feel good !
void CTrackerTestView::OnLButtonDown(UINT nFlags, CPoint point)
{
TRACE( "CTrackerTestView::OnLButtonDown\n" );
CRectTracker tracker;
BOOL bRetVal = tracker.TrackRubberBand( this , point, true );
CView::OnLButtonDown(nFlags, point);
this->PostMessage(WM_LBUTTONUP );
}
Thanks!
Max.
|
|
|
|
|
Bad idea, you should let mouse messages live normally.
I'll recommend to check out a MSDEV sample code called "DrawCli" : fine implementation there.
Back to real work : D-24.
|
|
|
|
|
Yep, but different approach, they draw the rectangle by hand with DrawFocusRect.
maybe I'll change ALL ( sigh ) my code to see it it can be done that way !
Don't worry, it's not that bad !
Thanks.
Max.
|
|
|
|
|
hi,
i've got dll and lib files that i need to combine in my project.
the dll & lib were created in BORLAND env.
the thing is that the compilation works but the linker says:
"fatal error LNK1136: invalid or corrupt file"
1- is there any problem importing lib from Borland to visual?
2- how to import the lib?
love,peace and harmony to everyone!
|
|
|
|
|
You need a VC lib file, not a Borland.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
MS did a fine job of making lib files proprietary. You not only need a .lib file created by MSDEV, you also need it in the right MSDEV version (for instance .lib files created with MSDEV 6 won't (by default) link with MSDEV 5).
Back to real work : D-24.
|
|
|
|
|
You'll have to LoadLibrary() and GetProcAddress().
Signature space for rent. Apply by email to....
|
|
|
|
|
Hi,
I've got a problem with a multilanguage project. At application start I read all GUI strings from a file (this is a must because our customer wants to change the texts) inside memory. If the user changes the language at runtime I have to change all the GUI strings.
No my problem: how can I change the tooltip and statusbar texts for buttons inside a toolbar?
Best regards,
Patrik Müller
|
|
|
|
|
Every toolbar button should have a string table entry for it with the same ID. It will be of the form:
Status bar prompt\nTooltip to be displayed.
Now by default the CMainFrame class uses the GetMessageString() function to return the status bar prompt for menu/toolbar buttons and tooltips. You will need to override this function and re-direct the code to get the string that you want from your loaded list.
Take a look at the functions default implementation and modify your own version from that.
Roger Allen
Sonork 100.10016
I have a terminal disease. Its called life!
|
|
|
|
|
OK,
I'll try it if I got time.
Many thanks for your help!
Best regards,
Patrik Müller
|
|
|
|
|
Is it possible to hide and show the main menu
of a MDI application ???
I'd like to let the menu to be not visible as default
and to show it when the mouse goes on its position.
(See taskbar behavior)
What have I to do ?
Thanks a lot !!!;)
|
|
|
|
|
To hide:
p=GetMenu();
SetMenu(NULL);
p->DestroyMenu();
To show:
p=new CMenu;
p->LoadMenu(MAKEINTRESOURCE(IDR_MAINFRAME));
SetMenu(p);
delete p;
I've tested it on a SDI and i found a problem on closing the program: the frame always assumes that the menu is present and attempts to destroy it. Probably you must - sometimes formally - have the menu loaded before closing.
rechi
|
|
|
|
|
I have used your indication in my project but
I have found a problem:
the debug version of a MDI project verifies
the menu status and ASSERT if the menu is not
visible.
So I can use this functionality only in release
version...
What do you think about this problem ?
Have you got any other indication ?
Thanks a lot!!
|
|
|
|
|
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
|
|
|
|