|
In my application I have a scroll view that I would like to insert other views. It all works wonderfully until the number of "other view" requires that the horizontal limit of the scroll view is exceeded (32768). At that point all any addtional other views are not placed in the scroll view correctly.
I can resize the scroll view to a long int, but CWnd is limited to CRect which only handles int's.
If anyone has any information it would be great.
I'm using MM_TEXT as the map mode.
Chris
|
|
|
|
|
In your WM_HSCROLL handler, call GetScrollInfo instead of using the values passed directly to the handler. This lets you circumvent the 16-bit limitation in the WM_HSCROLL message.
ChrisLang wrote: CWnd is limited to CRect which only handles int's
CRect is based on RECT , which supports 32 bit position values.
Software Zen: delete this; // <a href="http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx" rel="nofollow">Fold With Us!</a>[<a href="http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx" target="_blank" rel="nofollow" title="New Window">^</a>]
|
|
|
|
|
Gary,
Thank you for your response.
The problems stems from actually creating the view. I call new CmyView and then call CREATE for the CmyView object which is subclassed from CWnd. In one of the overridden methods of CWnd::Create you can specify the x and y position of the view. Initially I just use, 0, 0 for x and y. Then after reading more information from the file (CmyView is reading the file to create the window from the values in the file) I call the essentially call CWnd::MoveWindow (CmyView does not override this method of CWnd). Although the compiler allows me to actually pass in a number larger than 32768, the new view is placed at a value less than 32768.
The scroll bar and displaying the correct portion of the scroll window is working fine. The problem is all CmyView objects which occur after 32768, are being drawn on top of each other.
I had a work around by adding all CMyView into another layer and then placing that layer in the CScrollView. Basically what I was doing was creating 2 CWnd objects call them CMiddleView objects and making the height of the intial CMiddleView object as near 32768 as possible (if adding another CmyView made the bottom of the initial CMiddleView over 32768 then I add it to the second CMiddleView object). Next I'd position top the second CMiddleView at bottom of the initial view. Like I said the scroll view worked wonderfully and I could scroll basically 2*32768.
But then the customer had MORE data, and now I need to postion CmyViews from 0 to somewhere up around 85000.
Again, I'm not getting a compiler errors, but the CWnd derived objects are not being positioned correctly if the MoveWindow method is called with anything over 32768.
Chris
|
|
|
|
|
Chris - You might try a different mapping mode. It could get your scaling down to positions in the 0-32767 range.
Unfortunately, I have a feeling you may need to re-architect how you're handling your views.
Sorry I couldn't be more help; good luck.
Software Zen: delete this; // <a href="http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx" rel="nofollow">Fold With Us!</a>[<a href="http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx" target="_blank" rel="nofollow" title="New Window">^</a>]
|
|
|
|
|
Gary,
I thought about using a different mapping mode intitially but because the other mapping modes are "smaller" the actual placement on the screen is "larger" (i.e. 1 pixel in MM_TEXT is at least the larger than 1 in any of the other 4 modes).
I'll continue to plug away at the problem and when I figure it out I'll post something because I'm certain that I'm not the first person that has had to deal with this.
Chris
|
|
|
|
|
The answer seems to be that with my current versions (I down load updates regularly so I don't think the problem has been address just yet) that a CWnd object CANNOT handle MoveWindow and a value larger than 32768 (in a rect or specified as just integers). The code compiles but the window is not moved or resized as specified in the MSDN documentation.
For me the solution was to create a new view of type CWnd (call it CHolderView) and place it in the CScrollView and then place the CmyView objects into the CHolderView. The key is to make the CHolderView initially large enough to hold all my CmyView objects. If you try to resize the CHolderView you can't make it bigger than 32768 after it is created.
I'm also going to post this solution as its own message so others might be able to see it without having to follow this thread.
Thanks again Gary for your attempts at solving this dilemma.
Chris
|
|
|
|
|
Hi,
i want to code a custom mp3player (already coded it) to run from my webpage.
How do i create a component with or (*favor) without mfc?
so users visiting my http:/test.htm will
- install -ocx (or whatsoever)
- hear a mp3 played from my (component.mp3)
how do i do this? i have no idea at all.
|
|
|
|
|
Hi,I want to ask how I can get the EOF using CFile and CArchive classes.
Please, help me. Thank you.
|
|
|
|
|
If you read the MSDN documentation for either class's read method you will find: the return value may be less than nCount if the end of file was reached
--
Pictures[^] from my Japan trip.
|
|
|
|
|
SeekToEnd
will make the file pointer at the end of file data
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
CFile::Seek( 0L, CFile::end ) same SeekToEnd
|
|
|
|
|
Hello,
I am trying to play video inside a panel.
The problem is that i can't get a window handle for the planel and here is the code that i am wriiting:
pWindow->put_Owner (this->panel1->Handle);
[Error C2664]: 'IVideoWindow::put_Owner' : cannot convert parameter 1 from 'System::IntPtr' to 'OAHWND'
How can i fix this problem. My end goal is just to play the file in the panel not in a pop up window!!
Thanks
|
|
|
|
|
try out with this
pWindow->put_Owner ((OAHWND)this->panel1->Handle);
and tell me again...
Kifayatulah
CDigital Islamabad
Tel.03215309934
|
|
|
|
|
I want to learn how to use the Boost libraries for regular expressions. Can anyone give me a step by step on how to get RegEx and implement it into an MFC app? I would like to be able to search for string patterns in text document displayed in a CEditView or CRichEditView. Thanks.
Mark
|
|
|
|
|
|
Thanks. I somehow missed this.
Mark
|
|
|
|
|
I am trying to paste an information icon into my mfc project.
I found in internet that the way to do it would be something
like this:
BOOL MyAppDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CWinApp* pApp = AfxGetApp();
CDC* pDC = GetDC();
HICON hIcon;
if( pApp != 0 )
{
hIcon = pApp->LoadStandardIcon(IDI_INFORMATION);
bool b = pDC->DrawIcon( 20,230, hIcon );
}
ReleaseDC(pDC);
DestroyIcon( hIcon );
}
This is not working for me, the icon is not being drawn. So I changed this and
put it in a button event. So now when I press a button the icon is being drawn.
Why doesnt this work in OnInitDialog() ??
My other problem is that when my window goes into the background the icon disappears.
How should I draw the icon to be static in the gui?? Actually I would prefer to
paste it like a button or edit box instead to do it with code..Is there a way to do
this?
Thanks.
|
|
|
|
|
I think the icon doesn't work in OnInitDialog because the dialog is painted again, so the icon disappears very quickly.
You can put the icon-drawing code in OnPaint() .
OnPaint()<br />
if (IsIconic())<br />
{<br />
}<br />
else<br />
{<br />
CPaintDC dc(this);<br />
HICON hi = AfxGetApp()->LoadStandardIcon(MAKEINTRESOURCE(IDI_INFORMATION));<br />
dc.DrawIcon(10,10,hi);<br />
CDialog::OnPaint();<br />
}
About your last question, if you want a static icon on the dialog, you can put a picture control on it, and set the property: "type" to "Icon" and the "Image" to whatever icon you have in the project.
this is this.
|
|
|
|
|
|
hi,
I have wrote the code for excel addin using xlsdk in VC++ MFC. The call to DoModal fails in VC++ 7.0 but works fine with VC++ 6.0.
Code given below
__declspec(dllexport) xlAutoOpen()
{
//... piece of code
CControlPane dlg;
dlg.DoModal; //Fails in VC 7.0 but works fine with VC 6.0
}
mayank.jindal@mphasis.com
|
|
|
|
|
I've created many tables in a SQL Database. I'am using Ole Db to open its. Every tables except one I can open with the Propety DBPROP_IMMOBILEROWS in true mode, but only one of this tables can't open that way, the Prob must be false, why?, Any Suggestion? thanks....
propset.AddProperty(DBPROP_IMMOBILEROWS, false); propSet must be false, other way I have Open Error....
|
|
|
|
|
I have a inproc dll component and MFC Client. I wrote a mc file containing my user defined HRESULT. I am returning the custom HRESULT from the component in the following way:
<br />
if(SUCCEEDED(hr))<br />
{<br />
return E_FILESAVED;<br />
}<br />
where E_FILESAVED is my custom HRESULT.
In my client I use the following :
<br />
void* pMsgBuf;<br />
HANDLE ghResDll;<br />
char lpMsgBuf[BUFSIZE];
<br />
<br />
ghResDll = GetModuleHandle(NULL);<br />
DWORD dw = GetLastError(); <br />
CHAR szBuf[80]; <br />
sprintf(szBuf,"%u",dw);<br />
<br />
AfxMessageBox((LPTSTR)szBuf,MB_OK,0);<br />
::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |FORMAT_MESSAGE_FROM_HMODULE,<br />
ghResDll,hr,MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),<br />
(LPTSTR) &lpMsgBuf,BUFSIZE,NULL);<br />
AfxMessageBox((LPTSTR)lpMsgBuf,MB_OK,0);<br />
I see the correct hr (value) being returned in the client after my function in the component returns but the string is a null string.
Can anyone help me with this? Thanks in advance..
-Mandira
|
|
|
|
|
First, void* pMsgBuf; has been declared but not used. I think you should use pMsgBuf instead of the lpMsgBuf[BUFSIZE]; because the flag: FORMAT_MESSAGE_ALLOCATE_BUFFER causes memory to be allocated to the buffer, which you should deallocate using LocalFree(...);
And use FORMAT_MESSAGE_FROM_SYSTEM instead of FORMAT_MESSAGE_FROM_HMODULE .
Hope that helps.
this is this.
|
|
|
|
|
Hi,
Thanks for the reply. I had a LPVOID lpMsgBuf declared which i was using (not seen in posted code).
The reason I have used FORMAT_MESSAGE_FROM_HMODULE is because I have my own custom HRESULT codes defined in the mc (message compiler file) and their corresponding messages.
FORMAT_MESSAGE_FROM_SYSTEM only displays the system defined messages ..
and E_FILESAVED is a custom-defined message defined in mc file as follows:
<br />
MessageId = 2000<br />
SymbolicName = E_FILESAVED<br />
Language = English<br />
File Saved Successfully!<br />
Thanks!
-Mandira
|
|
|
|
|
You can take the contents of the newly-created .RC file, and place them in the .RC2 file for example. That should help. If you don't have a .RC2 file, then place the text directly in the .RC file.
this is this.
|
|
|
|