|
Is there anyway to reverse find index?
POSITION pos=0;
int index=5;
pos = LinkList.FindIndex(index)
pClass = (CClass*) LinkList.GetNext(pos)
pClass = (CClass*) LinkList.GetNext(pos)
Is there a function to get the index value?
Basically a revsere of
pos = LinkList.FindIndex(index)
Give the pos value and find the index value
|
|
|
|
|
You can always write one like this:
int FindObjectIndex(CObList *pList, CObject *pItem)
{
CObject *pListItem;
int iIndex = 0;
POSITION pPos = pList->GetHeadPosition();
while (pPos)
{
pListItem = pList->GetNext(pPos);
if (pListItem == pItem)
return iIndex;
iIndex++;
}
return -1;
}
onwards and upwards...
|
|
|
|
|
Doh I was afraid of that, have to go through the whole link list just to find the index value. Guess I will cheat by setting the new index value myself.
|
|
|
|
|
The FindIndex function basically does the same thing, iterating through the list n times and returning the element.
onwards and upwards...
|
|
|
|
|
Hi, I was wondering if I am given a DLL with a set of header files to use (of which i don't have the source to). Is there a way to create a new DLL (with a new set of header files) that uses the functions of the old DLL without giving access to the old header files? Is this possible? In short, I want to create a new wrapper DLL with a new set of header files without sharing information of the old headers. I've been looking all over the web and couldn't find anything. Thanks!
RCJ
|
|
|
|
|
Hi There
I don't know if I have understand your question correct, but my answer is, to what I have undertand :
I would create a new header file, called DllInterface.h which will declare all the functions/methods that you want to export. Afterwards, create a new class called CreatorDll, which will implement all the original methods. In this class, in your cpp file, only include all the header files you want to hide. In the corresponding header file include the Interface file. If you have some classes which you want to offer users of the dll, make creator functions in your creator class, which returns with instances of the corresponding classes.
Then the places where you want to use the dll, only include the headerfile for the creator.
This is the way I do, when I want to export some methods of class, which perhaps uses a lot of classes.
I hope this gives you an idea, or maybe can help you in the wanted direction.
Best regards,
Søren Madsen
Denmark
|
|
|
|
|
I think it can been make:
1.We create a dll project whitch the new header file.
2.at our dll project,we relocate the function to the old function in the old dll,use Loadlibrary("old.dll"); and GetProcAddress(...) can do it.
3.builder our dll project,so we get a new dll.
|
|
|
|
|
Greetings,
I have a CFormView child with an embedded CDialog resource in it. When focus is anywhere outside of this embedded resource I can get input messages in the CFormView::PreTranslateMessage no problem but as soon as focus goes into the embedded dialog the only place I can get the messages is in the CEmbeddedDialog::PreTranslateMessage method.
I have even tried to locate the CFormView from within the CEmbeddedDialog::PreTranslateMessage method and call SendMessage on it from the data in pMsg but it still doesn't get into the CFormView.
Any ideas? Thanks!
|
|
|
|
|
Hi
I've written a DLL that uses Windows Sockets. The DLL gets inject into another process by calling WriteProcessMemory & CreateRemoteThread. The injecting and calling all works fine. The Target App loads the DLL and the Client even gets connected to the Server. But if i try to send something from the Server to the Client nothing happens. I don't know if the Client can send data to the Server. I'm using a multithreaded Server that can accept more than one connection by converting the CSocket Object to a DWORD. I don't know where the problem is.
MFG
RedDragon2kx
P.S. THE SOFTWARE IS NOT USED TO CAUSE DAMAGE TO SOFTWARE OR HARDWARE
Unix and C are the ultimate computer viruses.
|
|
|
|
|
Continuing on the Doc View architecture
Document Object = D
Server = S
View = A
from A I need to send user requests to S . These requests have to be processed via D as D houses and maintains the server object
Say within a routine in A
void A::ClickedServerUpdateButton()
{
CDocument *doc = GetDocument();
doc->????
}
Now Say D has a routine
void D:: SendRequest()
{
}
How do I invoke this from A .
If I need to call SendRequest
Is this a good practise to do the following within A.cpp
#include "NewDocument.cpp"
..
..
..
void A::ClickedServerUpdateButton()
{
// Is this
D *doc =(D*) GetDocument();
doc->SendRequest();
}
Engineering is the effort !
|
|
|
|
|
Hello my best friends,
I'm a beginner to Visual C++ programming, so I have some "stupid" questions for you and I hope you guys to help me.
I'm working on my own very simple chatapplication, but I encounterd some problems. I've made a client and a server part, I've tested it out but I had the problem that I couldn't send a text string. My serverside establishes a connection with the clientside ( I know it because I put some control messages to be sure there is a connection).
But when I try to send a peace of text, it does nothing except that it shows the sending text on my display and the receiver part shows nothing on the display. I used the following code to send a string:
void CSimComDlg::OnSend()
{
m_Message.GetWindowText(strMESSAGE);
m_pArOut->WriteString(strMESSAGE);
m_pArOut->Flush();
m_MsgDsp.SetWindowText(_T(Name+":"+strMESSAGE+"\r\n"));
strMESSAGE.Empty();
}
And to read a received string:
void CSimComDlg::ReadReceive()
{
m_pArIn->ReadString(strMESSAGE);
m_MsgDsp.SetWindowText(_T("Chatter:"+strMESSAGE+"\r\n"));
strMESSAGE.Empty();
}
m_pArOut and m_pArIn are CArchive pointers (I use this in combination with CSocketFile to send data over internet).
Is there something wrong with these codes?
I've seen some other example codes on the internet, they include also the length of the message to send and they check also the buffer if there's more data coming in. But are they neccesary to put them in my code?
I hope you can help me boyzz
If my application works, I forget all my problems.
If my application works, I forget all my problems.
|
|
|
|
|
|
Thnx for the reply on my message,
But actually I don't just want to copy some prepared codes where you just have to code for example: SendText("Hi how are you") and the rest goes by itself.
I want to know what I've done vrong with my code and what do I have to change in my code or what code do I have to add in my code.
I've seen some peaces of code using WriteString() and ReadString() with CArchive (wich needs also CSocketFile). I've seen also some codes using Send() and Receive of CSocket class.
When I know how to use these codes I can alway encapsulated them just like NDK application you reffered it to.
So I hope you can help me more about WriteString() and ReadString() and I hope other guys can help me too, you are all welcome.
If my application works, I forget all my problems.
|
|
|
|
|
I am trying to pass a pointer to an object to a function, and have this function to the work of creating the object. Although the object is assigned properly within the method, upon returning to the calling function, the object pointer that was passed has not changed. Could someone explain to me what is going on here?
I have an abstract class A and an inherited class B
<br />
Class A { doSomething(){} }<br />
<br />
Class B : A{<br />
int x;<br />
B(int x){<br />
this->x=x;<br />
}<br />
}<br />
Now, I want my class C to have a method that creates a pointer to A, passes this to a function, and that function changes the pointer so that it points to a new object of type B.
<br />
Class C {<br />
getB(){<br />
A* a;<br />
FindIt(a);
}<br />
<br />
FindIt(A* a){<br />
int x=1;
B* b = new b(x);
a = (A*)b;
}<br />
}<br />
So, when I debug...after the call to Find It, a is not pointing at the correct memory address. What is going on?
whitee
|
|
|
|
|
You were passing a copy of the "a" pointer to FindIt(). You need to pass it by address(or reference).
Class C {
getB(){
A* a;
FindIt(&a);
}
FindIt(A** a) {
int x=1;
B* b = new b(x);
*a = (A*)b;
}
}
|
|
|
|
|
I have initialized DX7, i have two buffers.
But I cannot figure out wich interface that have functions for rectangles, lines and so on.
the area I want to paint on is a LPDIRECTDRAWSURFACE7 interface. Can I through that get hold of an interface that has line/arc/rectangle functions?
|
|
|
|
|
I'm trying to use wglUseFontBitmaps to display some text in OpenGL.
now, it's working fine, I'm doing something like :
m_iDisplayListBase = 1000;
glDeleteLists(m_iDisplayListBase, 256);
m_iDisplayListStart = glGenLists(256);
BOOL b = wglUseFontBitmaps (m_hDC, 0, 256, m_iDisplayListBase);
...
glListBase(m_iDisplayListBase);
glColor4f( 0.8, 0.1, 0.8, 1);
glRasterPos3i( 20, iHeight-10 - m_iFontHeight, 1);
glCallLists (24, GL_UNSIGNED_BYTE, "Hello Win32 OpenGL World");
Now, the questions.
1 - When using glGenLists to generate a number of empty display lists ( to be filled by wglUseFontBitmaps ), it returns the number (ID?) of the first display list ? so, should the argument to glListBase be ID + someArbitraryValue ? or will this be done automatically ?
2- When using wglUseFontBitmaps, do I need to do something else if I want to recreate the display lists for a different font size ? can I reuse the same "font bitmaps" ?
Thanks.
Max.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Maximilien wrote:
1 - When using glGenLists to generate a number of empty display lists ( to be filled by wglUseFontBitmaps ), it returns the number (ID?) of the first display list ? so, should the argument to glListBase be ID + someArbitraryValue ? or will this be done automatically ?
What is actually happening is that the glListBase(n) is setting the base of the next set of calls to n. In your case your Display list base index for your font. the function glCallLists() will generate one call per ascii value, thus you generate a full 256 count for your font. But the actual call is the combination of the last glListBase(n) adding the ascii value from the glCallLists() for each character.
Maximilien wrote:
2- When using wglUseFontBitmaps, do I need to do something else if I want to recreate the display lists for a different font size ? can I reuse the same "font bitmaps" ?
I have 3 different font selections in my program. Remember that the callLists is the sum of the base plus the ascii value. So you allocate a new set of 256 lists, I would suggest switching to an index variable name that reflects the font so you don't get confused.
However, remember that your driver may handle display lists in system memory or compiled and stored on the graphics card. You are generating 256 bitmap image display lists for every font. If you want to have multiple fonts on the screen at the same time, you will need three different sets of display lists. If you want the user to choose his font, do so ahead of building the font, and generate only one from the user definition. Don't use more memory than you need to. You can also cheat, make sure the text is in 7bit form (0-127 ASCII) and only generate 128 display lists. If you do, don't forget to check the string or you will get unknown results for any >127 values.
I rewrote this code as I pasted to remove some "stuff" hope it helps. You can also look into texture based fonts which may be much faster on some hardware. Google for OpenGL tutorials at "Nehe" and you will find text tutorials.
<br />
int BuildFont(char *fontname, int point, int bold)<br />
{<br />
GLint base;<br />
HFONT__ *font;<br />
struct HDC__ *h_DC;<br />
<br />
base = glGenLists(256);<br />
font = CreateFont(point,
0,
0,
0,
bold ? FW_BOLD : FW_NORMAL,
0,
0,
0,
ANSI_CHARSET,
OUT_TT_PRECIS,
CLIP_DEFAULT_PRECIS,
ANTIALIASED_QUALITY,
FIXED_PITCH,
fontname);
<br />
h_DC = GetDC(NULL);<br />
SelectObject(h_DC, font);
<br />
wglUseFontBitmaps(h_DC, 0, 256, base);
return base;<br />
}<br />
m_LargeTextBase = BuildFont("Arial Bold", LargeTextPitch, LargeTextBold);<br />
m_SmallTextBase = BuildFont("Arial Bold", SmallTextPitch, SmallTextBold);<br />
m_MediumTextBase = BuildFont("Arial Bold", MediumTextPitch, MediumTextBold);<br />
...<br />
glListBase(m_SmallTextBase );<br />
glCallLists(strlen(string), GL_UNSIGNED_BYTE, string);<br />
...<br />
glListBase(m_MediumTextBase);<br />
glCallLists(strlen(string), GL_UNSIGNED_BYTE, string);<br />
...<br />
glListBase(m_LargeTextBase);<br />
glCallLists(strlen(string), GL_UNSIGNED_BYTE, string);<br />
<br />
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Thanks for the Nehe reference, I will look at those tutorials tonight ...
I thought about using a couple of different font size display lists. I will make my life a bit easier; maybe that will be enough.
Thanks again.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I have C background but I need something like pointer so store two double variable data. Could anyone show me how or post some tutorial website here? Thanks.
|
|
|
|
|
One way:
double d1 = 5.1;
double *p1 = &d1; Another:
double *p1 = new double;
*p1 = 1.8;
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thx
I am using VC++, any easier class in MFC? The way you used seemed like C.
|
|
|
|
|
jw81 wrote:
any easier class in MFC?
What I provided was not easy?
Are you sure that you understand what you are asking? A pointer in C is the same pointer in C++. Encapsulating a simple pointer into a C++ class is unnecessary.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
My mistake, I was thinking abt linked list. Sorry abt the confusion. Does VC++ linked list same as C?
Thanks.
|
|
|
|
|
yes; all C constructs are C++ compatible.
but I would suggest using either MFC collections or STL collections
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|