|
It's a legacy from the 16bit days (only applies to Win9x, not 2000/XP). Check this article[^]. Seems like you will have to create your own scroll view deriving directly from CView .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for the answer Joaquín
Mick
|
|
|
|
|
Just in case anybody finds this post doing a google search or something, I found a solution to the problem at codeguru (http://www.codeguru.com/Cpp/W-D/doc_view/scrolling/comments.php/c3299/?thread=41682)
You just have to override onscroll as shown below:
BOOL <br />
CMyiew::OnScroll(UINT nScrollCode, UINT nPos, BOOL bDoScroll)<br />
{<br />
if (GetTotalSize().cx >= SHRT_MAX || GetTotalSize().cy >= SHRT_MAX )<br />
{ <br />
SCROLLINFO info;<br />
info.cbSize = sizeof(SCROLLINFO);<br />
info.fMask = SIF_TRACKPOS;<br />
<br />
if (LOBYTE(nScrollCode) == SB_THUMBTRACK)<br />
{<br />
GetScrollInfo(SB_HORZ, &info);<br />
nPos = info.nTrackPos;<br />
}<br />
else if (HIBYTE(nScrollCode) == SB_THUMBTRACK)<br />
{<br />
GetScrollInfo(SB_VERT, &info);<br />
nPos = info.nTrackPos;<br />
}<br />
}<br />
<br />
BOOL ret = CScrollView::OnScroll(nScrollCode, nPos, bDoScroll);<br />
<br />
<br />
return ret;<br />
}
|
|
|
|
|
Basically I want to loop through a link list that I have. It wouldnt be hard if in the link list their might be classes with different data types. So I am trying to use the void pointer. Because I dont know the data type of the class and I want to try and make a function that returns the address of the last class in the link list. I am able to use templates but everything works well until I try to get the void pointer in a class to equal the void pointer of the next class in the link list. I dont see why it doesnt work because I keep getting the error error C2227: left of '->NextObject' must point to class/struct/union. I am pointing to a class void pointer and Node is suppose to be a class so I dont understand why I am getting the error. I tried casting to fix this problem either I dont know how to do it well or it doesnt work to fix this.If anyone can help I would be extremly greatful.
#include <stdlib.h>
#include <windows.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string>
#include <conio.h>
#include <windows.h>
class Room
{
public:
void *NextObject;
Room();
};
Room::Room()
{
NextObject = 0;
name = "blue";
}
using namespace std;
Room *RoomHead;
template <class X> X *FindEndObject(X * Node)
{
void *Temp = Node;
while (Temp!=0)
{
Temp = Temp->NextObject;
cout << "MOo" << endl;
}
return Node;
}
void main()
{
void *NewRoom = FindEndObject(RoomHead);
system("PAUSE");
}
|
|
|
|
|
A void* doesn't have a NextObject method. You would need to cast this to the appropriate object with something like
Room* tmpRoom = reinterpret_cast<Room*>(Node)
tmpRoom will be null if the cast fails.
|
|
|
|
|
Room* tmpRoom = reinterpret_cast(Node)
Ummm... static_cast would suffice (and in general is preferrable to reinterpret_cast .)
tmpRoom will be null if the cast fails.
Oh, this behavior is only provided by dynamic_cast , and this type of cast can only be applied to convert from a virtual class to a virtual class, which is not the case. So, IMHO static_cast should be used, and the cast does not fail ever (of course, if Node didn't point to an actual Room object, then the program could crash or whatever.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I tried doing so and with a few changes I finally got the program to compile with this modify function
template <class x=""> void *FindEndObject(X *Node)
{
X* Temp1;
if(Node->Next==NULL)
{
return Node->Next;
}
void *Temp = Node->Next;
cout << "Hey Friend" << endl;
while (Temp!=NULL)
{
cout << "Hey Friend" << endl;
Temp1 = reinterpret_cast<x*>(Temp);
Temp = Temp1->Next;
}
return Temp;
}
But not the problem is that their is a runtime error at if(Node->Next==NULL) I dont understand why their would be a error if I am trying to see if Next == Null;
|
|
|
|
|
But not the problem is that their is a runtime error at if(Node->Next==NULL) I dont understand why their would be a error if I am trying to see if Next == Null;
Maybe Node itself is null? Or maybe you're pasing an invalid pointer.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Sorry I didnt see the post before I posted my last message and I tried to fix my program using the advice. I am still receiving the same runtime problem which stops at while (tmpRoom->Next!=0) Node shouldn't be NULL because Node would be a pointer to Room *RoomHead. Which is a global object. RoomHead->Next should = 0 because in the room constructure Next = 0; So FindEndObject should just return the value of tmpRoom because their is only one object in the link list. I tried every way to use the static_cast and I still cant get it to work. I am not even sure if I am doing it 100% correct. I dont want anyone to give me the code for the function because I will like to learn exactly how to do it my self. But if anyone could give me a little more detail hints I would appreciate it alot because right now I am not 100% sure how to implement the advice I am getting to my code. I guess because of the fact I never used void pointer or used any form of cast.
This is how my program looks so far
#include <stdlib.h>
#include <iostream>
class Room
{
public:
void *Next;
Room();
};
Room::Room()
{
Next = 0;
}
using namespace std;
Room *RoomHead;
template <class X> X *FindEndObject(X * Node)
{
X* tmpRoom = Node;
while (tmpRoom->Next!=0)
{
cout << "We Got Here" << endl;
tmpRoom = static_cast<X*>(tmpRoom->Next);
}
return Node;
}
void main()
{
void *NewRoom = FindEndObject(RoomHead);
system("PAUSE");
}
|
|
|
|
|
RoomHead is a pointer not an object. As such it has never called the constructor.
Declare it as
Room RoomHead
instead.
Dave
|
|
|
|
|
Lol thank you alot. I can't believe I didn't notice that. Thanks to everyone who helped me with my program.
|
|
|
|
|
You should question any design that entails objects being cast from void*. In general it's just plain bad.
But, that's just my opinion... I could be wrong.
|
|
|
|
|
Hi, i've got the following line in my app:
printf("Press Enter to continue\n");
...
clrscr();
i want to display the message until the user presses enter and then clear the screen.
what command should i use for that?
I need only ANSI C commands
i remember that in pascal you can use
readln;
thanks!
|
|
|
|
|
How about:
do
{
printf(...);
} while (getch() != 0xa);
clrscr();
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
#include <conio.h>
getch();
getch will wait until any key is pressed - test the return for
'\n' if you want the enter key.
do
{
ret = getch()
}
while (ret != '\n');
Dave
|
|
|
|
|
I cannot get specific dates to go bold in the DateTimeCtrl. I want to specify which days are bolded in the popup calendar. I do the following:
OnDropdownDateTimePicker(...)
{
CMonthCalCtrl * cal = m_ctrlDTP.GetMonthCalCtrl();
MONTHDAYSTATE *md;
short len;
SYSTEMTIME tFrom, tTo;
if (cal)
{
cal->ModifyStyle(0, MCS_DAYSTATE); // change style to allow daystates
len = cal->GetMonthRange(&tFrom, &tTo, GMR_DAYSTATE);
md = new MONTHDAYSTATE [len];
memset(md, 0, sizeof(MONTHDAYSTATE) * len);
BOLDDAY(ms[0], 1); // MS macro to set day 1 of first month bold
cal->SetDayState(len, ms);
}
}
and nothing happens.
Anybody know what I am missing?
Thanks
Dave
|
|
|
|
|
DRHuff wrote:
Anybody know what I am missing?
Per MSDN:
After creating the control, you can change all of the styles except for MCS_DAYSTATE and MCS_MULTISELECT. To change these styles, you will need to destroy the existing control and create a new one that has the desired styles.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thanks.
I missed that completely.
Dave
|
|
|
|
|
How do I stop VC from removing NULLs from my string. I have to have nulls filling up 53 bytes before the begining of my message header...is there a way to stop VC from removing these when I send the packet over TCP/IP?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Without seeing the code that is "removing NULLs from my string", any answer would be a guess at best.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Here is my code snippet:
<br />
char sHeader1[54]={"\x00"};<br />
CString sHeader2;<br />
sHeader2.Format("%s rest of message header here", sHeader1);<br />
m_sConnectSocket.Send((LPCTSTR)sHeader2, sizeof(sHeader2));<br />
return 1;<br />
When I look at the packet on the other end, I do not see the nulls. It looks as though it removing them. This there a way to stop VC from doing this?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Try this :
<br />
<br />
char message[128];<br />
memset( message, 0, sizeof( message ) );<br />
strcpy( &message[53], " rest of message header here" );<br />
m_sConnectSocket.Send( message, 81 );<br />
<br />
__________________________________________
a two cent stamp short of going postal.
|
|
|
|
|
Nope. It seems that as soon as the socket sees those nulls it stops sending. If i send the message like you suggest I get nothing. But if I take out the memset (nulls) and send the string....it sends it.
I'm thinking that the people that made up this custom packet, are missing something.
Could this have anything to do with me passing data from a PC to a main frame?
This packet is based on the DMPP-2020 Message Layout.
Thanks for the help
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Tom Wright wrote:
m_sConnectSocket.Send((LPCTSTR)sHeader2, sizeof(sHeader2));
Why are you only sending 4 bytes?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Sorry your right. After sending I only get 4 bytes...but still not the leading nulls.
This has really got me puzzled.
Tom Wright
tawright915@yahoo.com
|
|
|
|