|
Scroll doesn't work by itself, you need to catch the scroll events, and make sure your code adjusts it's display accordingly. You also need to set the range of the scroll bars.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
how to implement it? Can u give some tutorials,articles,or some link that can be helpful..pls
thx
|
|
|
|
|
What version of VC are you using ? Whatever it is, you can set an event handler for each of the two scroll events ( but if I know which one, I can tell you exactly where ), and then you force a redraw with Invalidate(), and your drawing code takes the scroll position into account. I don't know of any tutorials, off hand, sorry. I'd be surprised if this site didn't have any.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I'm using VC 6.0. I already make the event handler. On where I should write my drawing code? Btw...what is the keyword for finding thw tutorials(I try "repainting window" keyword, but I didn't find any suitable articles)
thx...
|
|
|
|
|
firebolt77 wrote:
On where I should write my drawing code
Drawing code is ALWAYS in OnPaint. Invalidate(); is all the code you need to put in a scroll event to force a repaint.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thx...but I'm still confuse on the drawing code
I'm still new in MFC so I'm still lack of knowledge in MFC
thx anyway..
|
|
|
|
|
Well, what are you drawing ? How do you draw it now ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
just ordinary dialog box with tab control, tree control, button, edit box, etc. I want the dialog box can be resize to smaller size, and I can use the scroll bar to see all of the frame. Sorry for the bad english...but I hope you understand what I mean
thx..
|
|
|
|
|
Oh, OK. Well, I'd have thought a CFormView would handle that by itself. There's no painting involved here - your controls all need to be on some sort of control that you can position, otherwise you need to call SetWindowPos on all of them to move them, which is kind of ugly.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hmm..but I'm using CDialog base class. Can I use the method?
thx..
|
|
|
|
|
Yeah, I guessed that. You need to do what I said as an alternative, get a blank control ( that is, one that gives you a surface, but nothing on it, probably the control base class ), set out all your controls on that, and move it's location using SetWindowPos in response to the scroll bars. So the scroll range for X is the width of your control - the width of the window, and the same for the Y. Then when your scroll event occurs, you set the window position of the control to be the offset of the scroll pos, so if hte X scrollbar is set to 20, then the X position is -20, so the first twenty pixels of the control are to the left of the left edge of the main window.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
Hi geeks... I mean guys guys...
I need to use a very large integer that does not fit in a long. So I attempted using _int64 and the values are at least stored in the declared variable. However if I try to send it to the screen, it gives me this compiler error...
error C2593: 'operator <<' is ambiguous
Can anyone give me a simple explanation and solution? Is there any other place I need to be aware of where I'll run into trouble if using this data type?
Thanks a bunch!!!
|
|
|
|
|
knapak wrote:
error C2593: 'operator <<' is ambiguous
operator << is not defined for __int64. Therefore it has to try and cast it to something else ( which is plainly not going to work BTW ), and it can't decide what it should cast it to, hence the operator is ambiguous. You probably have to define your own operator <<, and I guess then any other STL operation you try to do, that is type specific.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello,
The __int64 is not supported by the standard, but it is rather compiler specific. The C standard has support for a 64 bit integer: long long . See here[^] for more information.
You always can write the number in hexadecimal in two steps: first write the upper 32 bits and then the lower 32 bits.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Hello all.
As an assignment, I'm trying to design front end for a database prepared in Ms Access using Visual C++. I'm using ODBC.
I'm designing an SDI Application with Multiple Views. The parent view is "Employee" and the child view is details about "core Staff members", if an employee is a Core staff member, clicking the button for "Core Staff" takes you to another view, with details regarding the employee. This child view has a button which takes you back to the parent view, say "Employee View".
Now, the problem is that when I click the "Core Staff" button, I get the new view if the current employee is a core staff member, but the problem is that the new view is "un-clickable" I cant click anything, If I try clicking something the window freezes on me. I can however navigate through the fields using the tab key, or the short cut keys. However, when I select the "EMployee View" button and press enter, I get the message for Invalid View ID, which is supposed to be displayed if the "View doesnt exist".
Here's the code for the "SelectView" function in the CMainFrame class.
[code]
void CMainFrame::SelectView(UINT ViewID)
{
CView* pOldActiveView = GetActiveView();
CView* pNewActiveView = (CView*)GetDlgItem(ViewID);
if(pNewActiveView == NULL)
{
switch(ViewID)
{
case CORE_VIEW:
pNewActiveView = (CView*)new CCoreView;
break;
default:
AfxMessageBox("Invalid View ID");
return;
}
CCreateContext context;
context.m_pCurrentDoc = pOldActiveView->GetDocument();
pNewActiveView->Create(NULL, NULL, 0L, CFrameWnd::rectDefault,this,ViewID,&context);
pNewActiveView->OnInitialUpdate();
}
if(ViewID == CORE_VIEW && ! ((CCoreView*)pNewActiveView)->IsCore())
{
AfxMessageBox("Current Employee is not a Core Staff Member");
return;
}
SetActiveView(pNewActiveView);
pOldActiveView->ShowWindow(SW_HIDE);
pNewActiveView->ShowWindow(SW_SHOW);
pOldActiveView->SetDlgCtrlID(m_CurrentViewID);
pNewActiveView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
m_CurrentViewID = ViewID;
RecalcLayout();
}
[/code]
The code for the Button on the "Employee View" is:
[code]
((CMainFrame*)GetParentFrame())->SelectView(CORE_VIEW);
[/code]
Similarly, the code for the button on the "Core VIew" is:
[code]
((CMainFrame*)GetParentFrame())->SelectView(EMPLOYEE_VIEW);
[/code]
I'm following "Ivor Horton's" "Beginning Visual C++6". Since, the "Parent View" alread exists, GetDlgItem() should return the address of the view, otherwise return Null.
I dont know whats wrong here.
Can anyone please help?
Thanks
and here are the screenies.
EMPLOYEE VIEW
[img]http://img196.imageshack.us/img196/282/employee9ps.jpg[/img]
CORE VIEW
[img]http://img211.imageshack.us/img211/7392/core5nq.jpg[/img]
Thanks again.
|
|
|
|
|
Say i have a client and server. Server listening at 10.10.10.10 on port 4000. Client connects from 11.11.11.11. Server sends back a message saying:
"You are connected from <ip> on port <port>"
Where having the server use GetPeerName would give the proper ip of 11.11.11.11, but the port will be some other number other than 4000 in my case. So the message to the client would say something like:
"You are connected from 11.11.11.11 on port 3000"
Should GetPeerName be returning 4000 as the port? Or is the port of the client just a random one?
|
|
|
|
|
Type: netstat -n
GetPeerName will return the "remote address" column (only a single item of course).
Don't try it, just do it!
|
|
|
|
|
Ok thanks. The client port is just a random one. I get it now.
|
|
|
|
|
I am starting a project soon and the contact wants to control the record volume settings from within the application. Is there a way to do this with sndvol32 or some other way without using DirectX? He is concerned about file size, that's why he doesn't wish to use DirectX. Thanks.
Bill Dennis
Orlando, FL
|
|
|
|
|
billiam904 wrote:
He is concerned about file size
Using DirectX does not create big binaries at all!
By the way: DirectX does adjust the volume of a single buffer, but not the volume of the system. You can use waveOutSetVolume to set the output volume.
Don't try it, just do it!
|
|
|
|
|
what would i use to set the Line In record level?
Bill Dennis
Orlando, FL
|
|
|
|
|
mixerSetControlDetails
Don't try it, just do it!
|
|
|
|
|
Hi,
I am quite new to vc++. I am doing a project in win32. I want to set timeout value for a while loop. I am checking a condition in a while loop. If that condition is not satisfied at all, instead of looping forever I want to set timeout value like 300 msec then exit the while loop. I want to do this with CreateEvent() and waitforsingleobject(), but I dont know how to do it exactly.
Can someone help me with sample code???
Thanks a lot.
|
|
|
|
|
You can't create an easy timeout loop that way. What kind of code is running in the loop? There are normally better ways.
Don't try it, just do it!
|
|
|
|