|
|
Here[^] is a Microsoft article that should help you.
It's time for a new signature.
|
|
|
|
|
Hi, in my CTrendView derived from CScrollView,i added two scrollbars inside the view.
I created it in OnCreate function.
int CTrendView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CZoomView::OnCreate(lpCreateStruct) == -1)
return -1;
HScroll.Create(SBS_HORZ|SBS_TOPALIGN|WS_CHILD|WS_VISIBLE,CRect(10,10,200,15), this, 1);
VScroll.Create(SBS_VERT|SBS_TOPALIGN|WS_CHILD|WS_VISIBLE,CRect(200,50,230,200),this, 2);
}
And i added code for OnHScroll and OVScroll also.
void CTrendView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
CRect r;
CClientDC d(pScrollBar);
HScroll.SetScrollPos(iHIndex,1);
int TmpiHIndex = iHIndex; biHIndexChanged = false;
if (pScrollBar == &HScroll)
{
if (nSBCode == SB_THUMBTRACK)
{
iHIndex = (int)nPos;
}
if (nSBCode == SB_LINEDOWN)
{
iHIndex++;
if (iHIndex > pScrollBar->GetScrollLimit())
iHIndex = pScrollBar->GetScrollLimit();
}
if (nSBCode == SB_LINEUP)
{
iHIndex--;
if (iHIndex < 0)
iHIndex = 0;
}
HScroll.SetScrollPos(iHIndex,1);
}
CView::OnHScroll(nSBCode, nPos, pScrollBar);
}
So my problem is when i scrolling the Window scroll,its not get scrolling.When i debug,i found after pressing windows scroll it goes to this OnHSCroll coding and actual scrolling is not working.What can i do?Help me.
Anu
|
|
|
|
|
What are you doing with the iHIndex later ?
You have to take that offset into account when you redraw your view.
|
|
|
|
|
Im using iHIndex in OnDraw() function
iHIndex = HScroll.GetScrollPos();
and assinging in SCROLLINFO
SCROLLINFO infoH;
infoH.cbSize = sizeof(SCROLLINFO);
infoH.fMask = SIF_ALL;
infoH.nMin = 0;
infoH.nMax = PageCount;
infoH.nPage = 1;
infoH.nPos = iHIndex;
infoH.nTrackPos = 1;
HScroll.SetScrollInfo(&infoH);
Im plotting some dynamic values as trend in a Rect and im using this scroolbar to scroll and see the previous trend.
THis scrollbar is working properly.
Problem in Window scrollbar,when i move that it,it again move to previous position.
Anu
|
|
|
|
|
I have a 32bit bitmap with alpha channnel . I am drawing it using gdi+ . but I am not getting the transparency . How to get the transparency usnig gdi+
Rajesh
|
|
|
|
|
How are you drawing it? Do you have any code you can share? (small piece)
|
|
|
|
|
Graphics graphics(hdc);//Handle to the device context
//Load the image from a file
Image image(L"test.bmp",FALSE); // test.bmp is 32bit with alpha channels for transparency
graphics.DrawImage(&image,0,0,image.GetWidth(),image.GetHeight());
Rajesh
|
|
|
|
|
You have to specify Colormatrix and load it via ImageAttributes'
SetColorMatrix() before using DrawImage()
Regards,
Spk
|
|
|
|
|
What will be color matrix values ???
Rajesh
|
|
|
|
|
Thats based upon your requirement... if you need to convert 80% of the bitmap alpha values use this sample one...
ColorMatrix colorMatrix = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.8f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
ImageAttributes imageAtt;
imageAtt.SetColorMatrix(&colorMatrix, ColorMatrixFlagsDefault,
ColorAdjustTypeBitmap);
Regards,
Spk
|
|
|
|
|
you understand wrong . I have 32bit bmp and talking about the alpha channel tranparency . not opacity of image .
Rajesh
modified on Friday, July 23, 2010 7:50 AM
|
|
|
|
|
If you call GetPixelFormat() on a 32-bit bitmap (.bmp) loaded with Image, it will return PixelFormat32bppRGB.
I've found that using PNG images works.
|
|
|
|
|
Can you share with some piece of code for help me
Rajesh
|
|
|
|
|
It's exactly the same, just load a .PNG file that has an alpha channel.
|
|
|
|
|
bResult = AddPrinterDriver(NULL, 3, (LPBYTE) &di3);
TRACE("%d", (int) GetLastError());
if (!bResult)
return FALSE;
The call to AddPrinterDriver fails returning FALSE, and GetLastError() returns ERROR_IO_PENDING. The Error Lookup tool shows for this error "Overlapped I/O operation is in progress."
What does this mean, and what should I do to work around this problem?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
If i check out the documentation of AddPrinterFriver[^], it doesn't mention anywhere that it sets the last error code in case of an error, are you sure you are not getting the error code of something called before AddPrinterDriver OR maybe something that was called inside AddPrinterDriver but doesn't really contain much of information about the problem?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
Strange, it used to say:
If the function fails, the return value is zero. To get extended error information, call GetLastError() .
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi all,
I am trying to read a file from a device connected to a serial port. I am using CreateFile() and ReadFile() methods to read the file. But my problem is when i am not using FILE_FLAG_OVERLAPPED parameter my processing becomes slow. I wanted to know why this is happening??
Can anybody help me in this?
Thanks in advance
|
|
|
|
|
I think that is quite hard to guess without actually seeing what you do and how you do it. My guess is that without overlapping your program blocks on the read operatin until there's data available to be read so the processing becomes "blocky". Do you know the difference between overlapped and non-overlapped IO?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
If you have not read it before you MUST read: http://www.flounder.com/serial.htm[^]
You'd think working with a serial port be easy, but it's far from.
Good luck,
Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
|
|
|
|
|
I would like to address several bytes of memory but different bits from different locations. The program I am using is on an embedded system and I need access to different pieces of the peripherals. Specifically when dealing with ports where something connected crosses multiple ports and I need a modular way to access them through a simple 'maskport = value' and you only need to modify some macros or a enum to change things instead of each functions code.
IS this even allowed or am I out to lunch? (I am using GCC)
For example: (this doesn't work btw but it was my attempt)
struct bits {
uint8_t b0:1;
uint8_t b1:1;
uint8_t b2:1;
uint8_t b3:1;
uint8_t b4:1;
uint8_t b5:1;
uint8_t b6:1;
uint8_t b7:1;
} __attribute__((__packed__));
#define SBIT(port,pin) ((*(volatile struct bits*)&port).b##pin)
struct FIELD {
uint8_t b0:1;
uint8_t b1:1;
uint8_t b2:1;
uint8_t b3:1;
uint8_t b4:1;
uint8_t b5:1;
uint8_t b6:1;
uint8_t b7:1;
};
struct FIELD test;
test.b0 = SBIT(0xE2, 0);
test.b1 = SBIT(0xE2, 4);
test.b2 = SBIT(0xE2, 7);
test.b3 = SBIT(0xEF, 2);
test.b4 = SBIT(0xEF, 3);
test.b5 = SBIT(0x07, 1);
test.b6 = SBIT(0x07, 5);
test.b7 = SBIT(0x07, 6);
test = 0x7A;
That way by assigning a value to test:
<br />
test = 0x7A;
0xE2:
<br />
0001 0000<br />
0xEF:
<br />
0000 1100<br />
0x07:
<br />
0010 0010<br />
|
|
|
|
|
If I understood, you can try with a union:
union FIELDEX
{
struct FIELD
{
uint8_t b0:1;
uint8_t b1:1;
uint8_t b2:1;
uint8_t b3:1;
uint8_t b4:1;
uint8_t b5:1;
uint8_t b6:1;
uint8_t b7:1;
} fld;
uint8_t val;
};
FIELDEX test;
test.val = 0x7A; // 0111 1010
test.fld.b0 = 1; // set bit 0
|
|
|
|
|
I would still have the problem of setting separate address bits, however your example would make a good compact bitfield definition.
I am trying to take bits from separate registers and create my own 'masked register' so when I write to my register it sends each bit to its specified bits in other registers.
test.b0 = SBIT(0xE2, 0);
test.b1 = SBIT(0xE2, 4);
test.b2 = SBIT(0xE2, 7);
test.b3 = SBIT(0xEF, 2);
test.b4 = SBIT(0xEF, 3);
test.b5 = SBIT(0x07, 1);
test.b6 = SBIT(0x07, 5);
test.b7 = SBIT(0x07, 6);
Hopefully this will show more clearly what I am after:
test = 0x7A;
|
|
|
|
|
Hi All
If I can delete a memory using delete keyword for memory allocated on heap using new keyword.
class A
{
} ;
A &a1 = * (new A ) ;
How to release memory which is holded by a reference.
|
|
|
|
|