Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

126 Neutral

About Sfpiano

  • Rank
    Advanced Member
  1. WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_LBUTTONUP: InvalidateRect(hWnd, NULL, true); break; case WM_PAINT: PAINTSTRUCT ps; BeginPaint(hWnd,&ps); gShaper->Skin(ps); EndPaint(hWnd, &ps); break; ... CShaper() { m_srcDC = CreateCompatibleDC(NULL); SelectObject(m_srcDC, m_hFadeBmp); } CShaper::Skin(PAINTSTRUCT &ps) { HDC srcDC = CreateCompatibleDC(ps.hdc); SelectObject(srcDC, m_hFadeBmp); SetBkMode(srcDC,TRANSPARENT); SetTextColor(srcDC,0xFFFFFF); HFONT font = CreateFontIndirect(&m_LogFont); SelectObject(srcDC, font); TextOut(srcDC, ...) } Each time I click on the frame, the new text gets drawn on top of the old text, so after a few clicks everything looks larger and more grainy. I assumed the InvalidateRect call would erase everything, but apparently not.
  2. Sfpiano

    Inherited template typedefs

    Wow that was quick. Thanks a lot; got it working now.
  3. // helper.h namespace Helper { template <class T> struct allocHelper { typedef T& reference; }; } // #include "helper.h" template <class T> class Tree : public Helper::allocHelper<T> { public: typedef typename Helper::allocHelper<T>::reference reference; void fn(reference r) { r = r; } } template <class T> class SelfBalancedTree : public Tree<T> { public: void fn2(reference rr) { rr = rr; } } fn() compiles fine, but I'm getting the following error in fn2(): error: `reference' has not been declared error: ISO C++ forbids declaration of `rr' with no type
  4. Quote:Original post by Kylotan C++ has the get(), read(), and readsome() methods on istreams which let you specify how much reading you want to do. Thanks, read() was what I was looking for.
  5. I need a way to read x characters from a file stream into a buffer without regard for any kind of delimiter. Every function I've seen stops at a newline or whatever delim character you specify.
  6. Well at least on the machine I'm running on, all the sockets start at 3 and keep increasing. But I wrote a loop to definitively find the highest socket, and it still doesn't work. I do also zero out the set before I start, and pass a copy of that set to select so that the original set doesn't get destroyed. I've also tried with just using one socket and still no luck. If I pass the set to select as a writable set before I call sendto(), that works, but I still get timeouts when I use it as a readable set.
  7. I have a DNS querying program using select() that works perfectly fine in windows, however when I try running it in linux, the call to select always times out. I was wondering if there were any inherent differences in select on windows vs linux that would be causing this. Here's a rough outline of my code in case it's helpful. int mySockets[]; for(i to numQueries) { mySocket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); ... FD_SET(mySocket, &set); } int top = mySocket[numQueries-1]+1; while() { readSet = set; select(top, &readSet, NULL, NULL, &time); }
  8. Sfpiano

    Access violations

    Quote:Original post by Zahlman Uh, in C++ we represent strings with std::string and avoid all that nonsense. Believe me, I would if I could. Quote:You should change: unsigned char temp[512]; I though that might be the problem, but I was trying to avoid having a bunch of malloc'd things to keep track of. Thanks guys.
  9. Sfpiano

    Access violations

    char* convert(const unsigned char* name) { char buf[512], *tt = NULL, *p = NULL; int i, val; tt = buf; while( 1 ) { val = *name++; if( val == 0 ) break; for(i=0; i<val; i++) { *tt++ = *name++; } *tt++ = '.'; } *(tt-1) = 0; p = (char*)malloc(strlen(buf)+1); strcpy(p, buf); return p; } unsigned char* decompress(unsigned short len, unsigned char* data, unsigned char* buf) { unsigned char temp[512]; int j, offset=0; for(j=0; j<len; j++) { if( (data[j] >> 4 & 0xc) == 0xc ) { unsigned char* ins = &buf[data[j+1]]; memcpy(temp+j, &buf[data[j+1]], strlen((char*)ins)); offset += strlen((char*)ins); j++; } else temp[j+offset] = data[j]; } temp[j+offset] = 0; return temp; } ... struct RR { unsigned char* name; } char inBuf[65536]; read(inBuf); RR rr; = &inBuf; unsigned char * pop = decompress(strlen((char*),, inBuf); char* out = convert(pop); In the above code, when I call decompress, it stores the correct value in pop. However when I call convert(pop), I get an access violation, because the value of the input parameter to convert is all garbled, instead of the value of pop.
  10. My program is being sent a paint message every 30 or so seconds even if I just sit there w/o moving the cursor or anything. It's screwing with my textboxes because the program just draws on top of them w/o erasing them and the text gets all blurry. Is there a way to see where the WM_PAINT message is coming from?
  11. Sfpiano

    "C++" Stl template errors

    I'm using VS2005 and have never gotten this error, which is why I'm confused. For now the way I have to get around it is to user str.append() for everything.
  12. Sfpiano

    "C++" Stl template errors

    Thing only thing I see is that I'm using an iterator to pass the string; is that the problem? void parse(string &input) { string str = input + string("y"); } int main() { vector<string> vec; vector<string>::iterator itr; for(itr=vec.begin(); itr!=vec.end(); itr++) { parse(*itr); } return 0; } With this exact code I get the same error in the parse function.
  13. std::replace(str.begin(), str.end(), "\t", ""); Gives me: error C2782: 'void std::replace(_FwdIt,_FwdIt,const _Ty &,const _Ty &)' : template parameter '_Ty' is ambiguous see declaration of 'std::replace' could be 'const char [1]' or 'const char [2]' Also std::vector<std::string> spaceVec; std::string amount; ... amount += spaceVec[1] + std::string(" "); Gives me: error C2784: 'std::_Vb_iterator<_MycontTy> std::operator +(_Vb_iterator<_MycontTy>::difference_type,std::_Vb_iterator<_MycontTy>)' : could not deduce template argument for 'std::_Vb_iterator<_MycontTy>' from 'std::basic_string<_Elem,_Traits,_Ax>' 1> with 1> [ 1> _Elem=char, 1> _Traits=std::char_traits<char>, 1> _Ax=std::allocator<char> 1> ] : see declaration of 'std::operator +'
  14. I have a custom control text box with a transparent background; I did this by ignoring the onEraseBkgd message. However I'm trying to add an image that pops up if the user hovers the mouse along the bottom of the control. So I don't want to erase the text region, just the bottom region whenever the image appears or disappears. I tried: RECT bottomBar; ... ::InvalidateRect(handle(), &bottomBar, true); but it didn't work.
  15. Ok, I disabled the onerasebackground message and put SetLayeredWindowAttributes() in my onpaint function before I do any drawing which got rid of the grey region behind the text. The problem now is anywhere there is text there's still a white box. I tried: SetLayeredWindowAttributes(handle(), 0xffffff, 0, LWA_ALPHA);
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!