|
|
<pre lang="
I am stumped again.
I have this macro which expect the parameter registerSAM to be a symbol , for example PIO_ODSR.
I like to pass such symbol to a function and just have no idea how to convert char* to such symbol.
The compiler is not much of a help, just flags an error.
This is how the macro is used now
P_CB[iIndex] = portREGISTER(digitalPinToPort(*TFT_LCD_ControlPins), PIO_OWER);
B_CB[iIndex] = digitalPinToBitMask(*TFT_LCD_ControlPins);
Like to replace the second paramater "registerSAM" symbol with a variable.
Here is a part of the compiler output with me using incorrect way to place the char* as a paramater:
sketch\A.h: In member function 'int TFT_LCD::TFT_LCD_AccessRegister(byte, char*, boolean, boolean, char*)':
sketch\A.h:31683:75: error: expected unqualified-id before '&' token
P_CB[iIndex] = portREGISTER(digitalPinToPort(*TFT_LCD_ControlPins),&(cRegisterType)); // PIO_ODSR); // STATUS register PIO_ODSR
^
sketch\AAA_SAMRegisters.h:21:49: note: in definition of macro 'portREGISTER'
#define portREGISTER(port,registerSAM) (&(port->registerSAM))
Any help would be appreciated.
"></pre>
|
|
|
|
|
Vaclav_Sal wrote: #define portREGISTER(port,registerSAM) (&;(port->registerSAM))
Since you already have a & character in the macro definition, why do you have one in the macro call?
Vaclav_Sal wrote: P_CB[iIndex] = portREGISTER(digitalPinToPort(*TFT_LCD_ControlPins),&(cRegisterType));
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
This was just an attempt to solve the problem, passing "just" char did not work either.
I thin I found a workaround / hack to fix this, but still like to know how to pass the symbol as a variable.
|
|
|
|
|
I do not see any macro here, and I really cannot understand what all the above is supposed to do. It would really help, as I have suggested many times, if you showed the actual code clearly, and within <pre> tags so it is readable.
|
|
|
|
|
#define portREGISTER(port,registerSAM) (&(port->registerSAM))
|
|
|
|
|
I think your excessive use of the addressof operator (& ) is confusing the compiler.
|
|
|
|
|
And I think you really do not know the answer and just wasting your time.
If you bother to follow the thread I did mention I tested it without the & and it did not work.
I suppose since I did not use code tags correctly it is my fault.
Thanks, go back to policing the posts. You do that very well.
Have a nice day.
|
|
|
|
|
|
hi all,
i draw a image when i preview it its display ok but at time of printing the image location and size is different. i really don understand whats going wrong here please help me for this.
i m using this to draw image.
Graphics graphics(pDC->GetSafeHdc());
Image myPNG(path);
if(myPNG.GetLastStatus()!=Ok)
{
return FALSE;
}
graphics.DrawImage(&myPNG, (INT)image_rect.left, (INT)image_rect.top, 300, 300);
return TRUE;
thanks in advance.
|
|
|
|
|
Your size parameter values need to be scaled for output to a printer. When drawing to the screen 300 is the number of pixels, but when drawing to a printer it is the number of dots. See SetMapMode function (Windows)[^].
|
|
|
|
|
|
sir now one more issue occur here when i print with multiple page.
on first page its drawimage correctly but after first page it return generic error.
i really dont understand what happen here.
please help me for this.
thanks in advance.
|
|
|
|
|
I suggest you open a new question, and provide proper details of both code and error. You can help to isolate the problem by using your debugger to step through your code.
|
|
|
|
|
Hi Friends,
My application don't want to create any entry in registry. If I comment SetRegistryKey(_T("Local AppWizard-Generated Applications")) then application throw an Assert failure. How to overcome from this problem.
Thanks,
S Shanmuga Raja
|
|
|
|
|
First show exactly what code is causing the assert; we cannot see your screen.
|
|
|
|
|
Richard MacCutchan wrote: we cannot see your screen. Come on, Richard, upgrade to the latest version so you can at least pretend to help. ScreenPeek v2.0 has been out for several months now.
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
I tried CrystalBall 1.1 but its all blurred.
|
|
|
|
|
shanmugarajaa wrote: ...then application throw an Assert failure. Exactly what assertion is being thrown?
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Hi Friends,
Where FindFirstFile function fetching all folders, sub folders and files details? whether this API fetching information from registry?
Thanks,
S Shanmuga Raja
|
|
|
|
|
No, it performs the same function as the command line command dir, and lists all files as specified by the selection mask. This is explained in detail in the MSDN documentation[^].
|
|
|
|
|
That's part of the underlying file system, be it FAT32 or NTFS. See here for the latter.
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
I have a MFC dialog application in which I have a gdiplus object that I use to draw images in real-time. Works fine if I don't want to do any changes to this object or its associated variables. But when I try to update them at runtime, it starts to increase my memory consumption.
So, my question is, how to safely update a gdiplus object at runtime.
Here is my code
LONG Width;
LONG Height;
LONG bpp;
LONG Stride;
BITMAPINFO* bmi;
BYTE* pDIBSectionBits;
HBITMAP hbm;
Graphics* imagedisp;
Bitmap* offscreenBitmap;
CWnd* Display;
CStatic m_ImageDisp;
OnInitDialog()
{
......
Width = 512;
Height = 512;
bpp = 8;
Stride = ((Width * bpp + 31L) & (~31L)) / 8L;
......
}
InitParams()
{
SetImageColor();
Display = GetDlgItem(IDH_IMAGE);
this->GetClientRect(&m_disp_rect);
Display->GetClientRect(&m_disp_rect);
m_ImageDisp.GetClientRect(&m_disp_rect);
imagedisp = new Graphics(m_ImageDisp.GetDC()->GetSafeHdc());
}
SetImageColor()
{
m_BUpdate = false;
if (bmi != NULL)
{
delete bmi;
bmi = NULL;
}
bmi = (BITMAPINFO *)new BYTE[sizeof(BITMAPINFO) + UCHAR_MAX * sizeof(RGBQUAD)];
bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi->bmiHeader.biWidth = Width;
bmi->bmiHeader.biHeight = Height;
bmi->bmiHeader.biPlanes = 1;
bmi->bmiHeader.biBitCount = (WORD)bpp;
bmi->bmiHeader.biCompression = BI_RGB;
bmi->bmiHeader.biSizeImage = 0; bmi->bmiHeader.biXPelsPerMeter = 0;
bmi->bmiHeader.biYPelsPerMeter = 0;
bmi->bmiHeader.biClrUsed = 0;
bmi->bmiHeader.biClrImportant = 0;
memcpy(bmi->bmiColors, USECOLORMAP?summercmap:greyscale, 256*sizeof(RGBQUAD));
hbm = ::CreateDIBSection(NULL, bmi, DIB_RGB_COLORS, (void**)&pDIBSectionBits, NULL, 0);
if (offscreenBitmap != NULL)
{
delete offscreenBitmap;
offscreenBitmap = NULL;
}
offscreenBitmap = new Bitmap(bmi, pDIBSectionBits);
m_BUpdate = true;
}
OnPaint()
{
CPaintDC dc(this); if (m_BUpdate)
{
BYTE *pCurRowPixel = (BYTE *)(pDIBSectionBits);
memcpy(pCurRowPixel, ImgBuff, Width*Height);
imagedisp->DrawImage(offscreenBitmap, 0, 0, Width, Height);
}
}
So whenever the user clicks a button to change between grayscale and color pallette, SetImageColor() is called. When I monitor the memory usage while clicking that button, I see its changing the way I expect it to, but the memory usage keeps increasing at a rate of ~300KB per click.
Is there any safer way to achieve what I am trying to do without memory leaks?
thanks
PKNT
modified 26-Feb-16 14:31pm.
|
|
|
|
|
do you ever call DeleteObject on the result from that CreadeDIBSection ? (you should)
|
|
|
|
|
Thanks Chris, that solved my memory leak issue.
PKNT
|
|
|
|