|
No it was not reply,he or she needs to a line code?
|
|
|
|
|
|
They answered to he/she so I used of small style I said previous it was not reply, for example I could said: you can use of WM_SHOWWINDOW!
|
|
|
|
|
Hamid. wrote: They asnwered to he/she so I used of small style I said it was not reply for example I could said: you can use of WM_SHOWWINDOW!
I understand that you are not a native english speaker (neither do I) but please, put some extra effort when replying. Use punctuation and things like this. Honnestly, I more or less understand half of your posts. For example, I looked at your sentence for one minute but I couldn't guess what the hell you're talking about
I don't say that to hurt you, but it doesn't make a lot of sense to post if nobody understands you...
|
|
|
|
|
I wrote the following code to save bitmap to a file. But what i am getting is a black image. This is my code Any suggestions
HWND hParent=NULL,hChild = NULL;
bool bRet = IsProcessRunning("view.exe");
hParent = ::FindWindow("WindowViewer", NULL);
counter++;
if (!hParent)
{
AfxMessageBox("not able to find WindowViewer class");
}
if(hParent)
hChild = ::FindWindowEx(hParent,NULL,"ViewPU",NULL);
if (!hChild)
{
AfxMessageBox("not able to find ViewPU class",NULL,NULL);
}
::SendMessage(hChild, WM_SYSCOMMAND, SC_HOTKEY, (LPARAM) hChild);
::SendMessage(hChild, WM_SYSCOMMAND, SC_RESTORE, (LPARAM) hChild);
::ShowWindow(hChild, SW_SHOWNORMAL);
::SetForegroundWindow(hChild);
::SetFocus(hChild);
RECT rc;
BYTE* m_pDrawingSurfaceBits=NULL;
BITMAPINFOHEADER bmpInfoHeader = {0};;
HBITMAP hbmDIBSection = NULL;
char* szAppName = "view.exe";
bRet = IsProcessRunning(szAppName);
if (!bRet)
{
::MessageBox(NULL,"Application is not running",NULL,NULL);
}
::SendMessage(hChild, WM_SYSCOMMAND, SC_HOTKEY, (LPARAM) hChild);
::SendMessage(hChild, WM_SYSCOMMAND, SC_RESTORE, (LPARAM) hChild);
::GetWindowRect(hChild, &rc);
HDC hDC = ::GetDC(hChild);
HDC hSrcMemDC = CreateCompatibleDC(hDC);
HDC hDstMemDC = CreateCompatibleDC(hDC);
long width = rc.right-rc.left;
long height = rc.bottom-rc.top;
bmpInfoHeader.biSize = sizeof(BITMAPINFOHEADER);
bmpInfoHeader.biBitCount = 24;
bmpInfoHeader.biPlanes = 1;
bmpInfoHeader.biCompression = BI_RGB;
bmpInfoHeader.biWidth =width;
bmpInfoHeader.biHeight = height;
bmpInfoHeader.biSizeImage = ((((bmpInfoHeader.biWidth * bmpInfoHeader.biBitCount) + 31) & ~31) >> 3) * bmpInfoHeader.biHeight;
hbmDIBSection = CreateDIBSection(hDC, (CONST BITMAPINFO*)&bmpInfoHeader, DIB_RGB_COLORS, (void**)&m_pDrawingSurfaceBits, NULL, 0);
HBITMAP hbmOld = (HBITMAP) SelectObject(hSrcMemDC, hbmDIBSection);
bRet = BitBlt(hDstMemDC,0,0,width,height,hSrcMemDC,0,0,SRCCOPY);
if (bRet == 0) {
DWORD d=::GetLastError();
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0,
NULL
);
::MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
::KillTimer(NULL,idTimer);}
BITMAPFILEHEADER bfh = {0};
bfh.bfType = 0X4D42;
bfh.bfOffBits = sizeof(BITMAPINFOHEADER)+sizeof(BITMAPFILEHEADER);
bfh.bfSize = bfh.bfOffBits+bmpInfoHeader.biSizeImage;
bRet = SetCurrentDirectory("c:\\testBitmap");
DWORD ret = GetLastError();
char filename[200];
char *temp = "test";
char *dir= "c:\\testBitmap\\";
int j;
j = sprintf(filename,"%s",dir);
j+= sprintf(filename+j,"%s",temp);
j+= sprintf(filename+j,"%d",counter);
j+= sprintf(filename+j,"%s",".bmp");
HANDLE hFile = CreateFile(filename,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
if (!hFile)
{
return ;
}
DWORD dwWritten = 0;
bRet = WriteFile(hFile,&bfh,sizeof(bfh),&dwWritten,NULL);
bRet = WriteFile(hFile,&bmpInfoHeader,sizeof(bmpInfoHeader),&dwWritten,NULL);
bRet = WriteFile(hFile,m_pDrawingSurfaceBits,bmpInfoHeader.biSizeImage,&dwWritten,NULL);
bRet = CloseHandle(hFile);
SelectObject(hSrcMemDC, hbmOld);
DeleteDC(hSrcMemDC);
|
|
|
|
|
Instead of this big code Cant you use GDI+
or you dont want to use GDI+?
Regards,
Sandip.
|
|
|
|
|
this application is developed in window sdk. So we have to use sdk only
|
|
|
|
|
subramanyeswari wrote: But what i am getting is a black image
Since you never assign m_pDrawingSurfaceBits buffer with image data, I think it is the correct result.
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
|
|
|
|
|
i am getting the data in the following line. I debugged and checked
hbmDIBSection = CreateDIBSection(hDC, (CONST BITMAPINFO*)&bmpInfoHeader, DIB_RGB_COLORS, (void**)&m_pDrawingSurfaceBits, NULL, 0);
Regards
|
|
|
|
|
OK and what say the debugger about the values inside the m_pDrawingSurfaceBits buffer?
I guess they are all zeroes.
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
|
|
|
|
|
Do you want to use of this code for save bitmap or you can use of other way?
|
|
|
|
|
I don't mind using the other code as long it is in SDK
Regards
|
|
|
|
|
I am reading a file and getting the key and values. I am putting the keys and values in the map. When I run the program I get many number of warnings
like...
warningC4786: 'std::_Tree<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,
std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::less<std::basic_string<cha
r,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::_Kfn,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::basi
c_string<char,std::char_traits<char>,std::allocator<char> > > >' : identifier was truncated to '255' characters in the debug information
c:\program files\microsoft visual studio\vc98\include\map(46) : see reference to class template instantiation 'std::_Tree<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::pair<std::basic_string<char,std::char_traits<
char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<cha
r> >,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::_Kfn,std::less<std::basic_string<char,std::char_traits<char>,std::allocato
r<char> > >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >' being compiled
F:\Main Project\Coding\DLL_logging_Utility\properties.cpp(41) : see reference to class template instantiation 'std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::a
llocator<char> >,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >' being compiled
THANKS
|
|
|
|
|
Never heard of google, do you ?
See here[^] what you can find with a very basic search.
|
|
|
|
|
i will strongly second Cedric. you already asked too much dumb question without event seeking yourself a bit about how to solve them first.
so in brief, GOOGLE IS YOUR FRIEND. don't feel lazy to ask it !
ok. then, either recompile in release mode to have these disapear, or add this in a header that is defining those template classes:
#pragma warning (disable: 4786)
|
|
|
|
|
Hi ,
I am trying to migrate my application from VC 2003 to VC 2005. My application uses a third party static library(I do not have the source code for that), which was linking fine in VC 2003. Now in VC 2005, its giving me a linker error . Please find the link error below.
*****************************************************************************************************
1>------ Build started: Project: MeasurementLibTestapp2005, Configuration: Debug Win32 ------
1>Linking...
1>Searching libraries
1> Searching Measurement.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\msvcprtd.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\lib\mfc80ud.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\lib\mfcs80ud.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\msvcrtd.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\kernel32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\user32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\gdi32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\msimg32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\comdlg32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\winspool.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\advapi32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\shell32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\comctl32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\shlwapi.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\uuid.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\oledlg.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\ole32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\oleaut32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\urlmon.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\OLDNAMES.lib:
1> Searching AMIL_VL.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\msvcprt.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\lib\atlsd.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\wininet.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\ws2_32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\mswsock.lib:
1> Searching Measurement.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\msvcprtd.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\lib\mfc80ud.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\lib\mfcs80ud.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\msvcrtd.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\kernel32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\user32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\gdi32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\msimg32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\comdlg32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\winspool.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\advapi32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\shell32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\comctl32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\shlwapi.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\uuid.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\oledlg.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\ole32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\oleaut32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\urlmon.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\OLDNAMES.lib:
1> Searching AMIL_VL.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\msvcprt.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\lib\atlsd.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\wininet.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\ws2_32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\mswsock.lib:
1> Searching Measurement.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\msvcprtd.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\lib\mfc80ud.lib:
1>Finished searching libraries
1> Creating library W:\AMI\src\radworks\radworks\MeasurementLibTestapp2005\Debug\MeasurementLibTestapp2005.lib and object W:\AMI\src\radworks\radworks\MeasurementLibTestapp2005\Debug\MeasurementLibTestapp2005.exp
1>Searching libraries
1> Searching Measurement.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\msvcprtd.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\lib\mfc80ud.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\lib\mfcs80ud.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\msvcrtd.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\kernel32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\user32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\gdi32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\msimg32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\comdlg32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\winspool.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\advapi32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\shell32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\comctl32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\shlwapi.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\uuid.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\oledlg.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\ole32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\oleaut32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\urlmon.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\OLDNAMES.lib:
1> Searching AMIL_VL.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\msvcprt.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\lib\atlsd.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\wininet.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\ws2_32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\mswsock.lib:
1>Finished searching libraries
1>Searching libraries
1> Searching Measurement.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\msvcprtd.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\lib\mfc80ud.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\lib\mfcs80ud.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\msvcrtd.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\kernel32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\user32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\gdi32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\msimg32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\comdlg32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\winspool.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\advapi32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\shell32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\comctl32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\shlwapi.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\uuid.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\oledlg.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\ole32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\oleaut32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\urlmon.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\OLDNAMES.lib:
1> Searching AMIL_VL.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\msvcprt.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\lib\atlsd.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\wininet.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\ws2_32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\mswsock.lib:
1>Finished searching libraries
1>Measurement.lib(bitmap.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) class std::basic_istream<char,struct std::char_traits<char> > & __cdecl std::operator>><char,struct std::char_traits<char> >(class std::basic_istream<char,struct std::char_traits<char> > &,unsigned char &)" (__imp_??$?5DU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAE@Z) referenced in function "public: bool __thiscall Bitmap::load_image(class std::basic_ifstream<char,struct std::char_traits<char> > &,bool,short)" (?load_image@Bitmap@@QAE_NAAV?$basic_ifstream@DU?$char_traits@D@std@@@std@@_NF@Z)
1>W:\AMI\src\radworks\radworks\MeasurementLibTestapp2005\Debug\MeasurementLibTestapp2005.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://w:\AMI\src\radworks\radworks\MeasurementLibTestapp2005\Debug\BuildLog.htm"
1>MeasurementLibTestapp2005 - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
*****************************************************************************************************
I have been trying to figure it out for days on end, but in vain.
Has it got anything to do with the project settings??(Like treat wchar_t as built in type, I tried changin this option but it gives me more linker errors.)
Or is it that the static library is trying to link to an earlier deprecated version of STL lib file and VC 2005 app is trying to link to newer one?
If anyone of you can help me with your suggestions for fixing this bu, It would be great help..
Thanks in advance.
Zameer
zameer.kh@gmail.com
|
|
|
|
|
did you correctly added the .lib to your linker settings ?
|
|
|
|
|
Hi, first of all thanks your time.
I have specified the lib correctly in linker settings(Project properties->Linker->Input->Additional dependencies)
Regards,
Zameer
zameer.kh@gmail.com
|
|
|
|
|
So this isn't really Visual C++ but still I hope it's ok I "pollute" the board
I need some help with some paint-related issues.
I'm trying to build a simple image viewer/editor - just for fun.
I have some problems when painting the bitmap though.
If the bitmap is smaller than the client area it works nice; it gets painted in the center of the area as I want.
If the bitmap is bigger than the client area both horizontally and vertically it also works beautifully. I can use the scrollbars in both directions and the image scrolls correctly.
The problem arises when the image is larger than the client area in only one of the two dimensions. In this case when I scroll I only get to see the background; in other words the newly exposed image area doesn't repaint when scrolling.
My pain handler is as follows:
void MyScrolledWindow::OnPaint(wxPaintEvent& event)
{
wxPaintDC dc(this);
if(m_theBitmap && m_theBitmap->Ok())
{
const wxRect rectUpdate = GetUpdateRegion().GetBox();
const wxPoint ptVirt = CalcUnscrolledPosition(rectUpdate.GetTopLeft());
wxMemoryDC mdc;
mdc.SelectObject(*m_theBitmap);
const wxRect rcClient = GetClientSize();
wxPoint upperLeft;
if(rcClient.GetWidth() > m_theBitmap->GetWidth() || rcClient.GetHeight() > m_theBitmap->GetHeight())
{
PaintBackground(dc);
wxCoord w = m_theBitmap->GetWidth();
wxCoord h = m_theBitmap->GetHeight();
int x = wxMax(0, (rcClient.width-w)/2);
int y = wxMax(0, (rcClient.height-h)/2);
upperLeft.x = x;
upperLeft.y = y;
}
else
{
upperLeft = rectUpdate.GetTopLeft();
}
dc.Blit(upperLeft, rectUpdate.GetSize(), &mdc, ptVirt, wxCOPY);
mdc.SelectObject(wxNullBitmap);
}
else
{
PaintBackground(dc);
}
}
I have fought with this problem the whole bloody day without being any nearer a solution so I really hope someone can spot what I'm doing wrong here.
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
|
|
|
|
|
Nevermind, I just solved it.
That's how good you guys are - I can sense the solution just thinking about you
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
|
|
|
|
|
Folks,
(using MSVC 6.0)
Not sure if I got the function names right. I have an situation where I need to determine if a double value is corrupted. I should be able to check this by using _isnan and _finite (Is Not A Number and Is Finite). Both these functions are defined in LIBCMDT.lib but they collide with definitions in a third party library I need and I can't compile.
So, I'm looking for source code for these two functions so avoid the collision problem. I've Googled them both but have not found a solution that seems ok (lot's of unix references).
TIA!
'til next we type...
HAVE FUN!! -- Jesse
|
|
|
|
|
I am pretty sure you can resolve conflict by not using you own functions. But I have those functions handy so I will give it anyway.
typedef __int64 Int64;
inline bool isInfinite(double A)
{
static const Int64 _kInfAsInt = 0x7FF0000000000000;
if ((*(Int64*)&A & 0x7FFFFFFFFFFFFFFF) == _kInfAsInt)
{
return true;
}
else
{
return false;
}
}
inline bool isNan(double A)
{
Int64 _exp = *(Int64*)&A & 0x7FF0000000000000;
Int64 _mantissa = *(Int64*)&A & 0xFFFFFFFFFFFFF;
if(_exp == 0x7FF0000000000000 && _mantissa != 0)
{
return true;
}
else
{
return false;
}
}
-Saurabh
|
|
|
|
|
Saurabh.Garg wrote: I am pretty sure you can resolve conflict by not using you own functions.
Not sure how. Here's the build output:
--------------------Configuration: ConstATE_B - Win32 Debug--------------------
Linking...
LINK : LNK6004: .\ConstATE_B.exe not found or not built by the last incremental link; performing full link
LIBCMTD.lib(ieeemisc.obj) : error LNK2005: __finite already defined in analysis.lib(isnan.obj)
LIBCMTD.lib(ieeemisc.obj) : error LNK2005: __isnan already defined in analysis.lib(isnan.obj)
.\ConstATE_B.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
Creating browse info file...
ConstATE_B.exe - 3 error(s), 0 warning(s)
Saurabh.Garg wrote: I have those functions handy so I will give it anyway.
Thanks! That should help.
'til next we type...
HAVE FUN!! -- Jesse
|
|
|
|
|
Those error are almost always due to linking different "types" of CRT in different modules. For example your main executable might be using "Multi-threaded Debug DLL" CRT but one of your other statically linked library might be using "Multi-threaded Debug" or may be just single threaded ones.
In this case I think analysis.lib is a static library and it is using a version of CRT different from the application you are linking it with. Make you all CRTs are of same type and those errors will go away.
-Saurabh
|
|
|
|
|
Found another similar function - _fpclass() .
For checking NaN, it returns status such as _FPCLASS_SNAN and _FPCLASS_QNAN . For infinity, _FPCLASS_PINF and _FPCLASS_NINF . Have a look at it. Might be useful.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|