|
I'll second that recommendation. Best getting started book on MFC for any level programmer. Problem is it's out of print but worth the price the used copies are going for nowadays.
|
|
|
|
|
Which Book is in out of print, I hope u r not mentioned clearly.
|
|
|
|
|
sach!! wrote: have just started learning VC++. Can anyone suggest me a good book for starting with VC++. I know C++ well. I dont have any idea of MFS, SDK etc.
Learn VC++ in 21 days! good book to start Vc++ step by step!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
In a Grid control (TstringGrid of BC++) when I click on the scroll bar a message box appears and in parallel the scroller scroll down (in win xp os). But in win2000 the Scroller scrolls only after closing the message Box. Can any body tell how to change the behavior in XP so that it works like win2000?
|
|
|
|
|
Hello all! i have been working on a project that has several forms, and one of them must be opened in the second monitor if available, i am a newbie in c++ but is there any way to achieve this?
many might laugh at me because i am different, i laugh at them because they are the same
|
|
|
|
|
Hi,
I am using Visual Studio 2005. I was using some macros in my code. What I found was that I was unable to reference __LINE__ macro. The output of macros was wrong. I have created a sample and following is the code snippet -
#define TMP_THIS_FILE SimpleTrace_cpp<br />
#define TMP_EVAL(_value_) _value_<br />
#define TMP_(Id) TMP_EVAL(TMPFUNC_) ## TMP_EVAL(Id) ## TMP_EVAL(_) ## TMP_EVAL(TMP_THIS_FILE) ## TMP_EVAL(__LINE__)<br />
<br />
#define doTrace TMP_(CALL)
At line number 22 in my CPP file, If I make a call to -
doTrace();
Then the output should be
TMPFUNC_CALL_SimpleTrace_cpp22()
Instead the compiler is generating -
TMPFUNC_CALL_SimpleTrace_cpp()
And I get a compiler error saying
e:\projects\temp\temp\SimpleTrace.cpp(22) : error C3861: 'TMPFUNC_CALL_SimpleTrace_cpp': identifier not found
Any idea whats going wrong with the compiler? Also do I have to add any compiler switches to use __LINE__ in VS 2005?
S o h a i l K a d i w a l a
modified 21-Apr-21 21:01pm.
|
|
|
|
|
After slogging for couple of hours on this problem, I found the cause.
Change the "Debug Information Format" setting on the C/C++ project setting tab. The setting that does not work is "Program Database for Edit and Continue"; the setting that works is "Program Database".
Thanks a lot to people at Decompile.com. The page with information can be found at http://www.decompile.com/cpp/faq/file_and_line_error_string.htm[^]
I battled this problem for past few hours, finally posted on this forum and found the solution myself in next 5 min
Posting the solution here incase it saves time for someone stuck with same problem in future.
Just curios, is this a known problem and documented somewhere?
S o h a i l K a d i w a l a
modified 21-Apr-21 21:01pm.
|
|
|
|
|
I have a SDI application - one CSplitterWnd and two CView derived panes, top and bottom. We all know that top pane remains "docked" and bottom pane's size changes while resizing main window. I need exactly the opposite: the top pane's size has to change and the bottom pane's height must remain fixed while resizing main window (just like there was a docked control bar at the bottom of the main window). Is this possible (and how)?
--
Vladimir Svrkota,
CardWare
Novi Sad, Serbia.
|
|
|
|
|
overload CMainFrm::OnSize(), you can do what ever you want to do there.
|
|
|
|
|
Thanks, LeeeNN
--
Vladimir Svrkota,
CardWare
Novi Sad, Serbia.
|
|
|
|
|
I'm trying to send and receive data using overlapped sockets and completion routines. Everything works fine, except that quite often the final WSARecv doesn't complete until after some kind of (VERY LONG) timeout. This is basically what my completion routine functions look like:
void CALLBACK OnReceiveComplete(...)
{
if(cbTransferred == 0)
{
printf("Done.\r\n");
}
else
{
printf("Received %d bytes.\r\n", cbTransferred);
WSARecv(..., &OnReceiveComplete);
}
}
void CALLBACK OnSendComplete(...)
{
printf("Sent %d bytes.\r\n", cbTransferred);
WSARecv(..., &OnReceiveComplete);
}
Obviously there is error checking and other things, but that is the gist of it.
Interestingly it doesn't happen on all attempts. I'm doing a simple HTTP GET, and it ALWAYS "hangs" on "www.google.com", but it NEVER does on "www.cnn.com". Does this have something to do with how the servers are setup, or is there something I can do about this? Right now I just forcefully close the socket if I don't get any response for a certain amount of time. I've seen lots of examples for IOCP and overlapped events, but NONE for overlapped completion routines. I haven't been able to figure out this problem for the longest time, so this is my last-ditch attempt to get an answer.
On a side note, if I use the WinInet functions asynchronously the problem goes away (but there are other issues with using WinInet so I want to avoid it). So obviously there must be some way to know when there is no more data to read. I just can't figure it out.
|
|
|
|
|
I am new to c++. i understand programming i am a advanced vb programmer, but i am just havin problems learning and applying all these new keywords. i am a beginnering in c but i have had experience with the very basic fundamental things.
i am reading through a book and they want me to draw a single bitmap on a client window and have it jump around on the window and not go out of the window boundries. The only thing that happens right now is it just draws it over and over all over the screen without removing the previous instance of the bitmap. THIS IS MY CODE.
void Game_Run()<br />
{<br />
<br />
int x = 0, y = 0;<br />
RECT rect;<br />
GetClientRect(global_hwnd, &rect);<br />
<br />
if (rect.right > 0)<br />
{<br />
x = rand() % (rect.right - rect.left);<br />
y = rand() % (rect.bottom - rect.top);<br />
DrawBitmap(global_hdc, "c.bmp", x, y);<br />
}<br />
}
void DrawBitmap(HDC hdcDest, char *filename, int x, int y)<br />
{<br />
HBITMAP image;<br />
BITMAP bm;<br />
HDC hdcMem;<br />
<br />
image = LoadImage(0,"c.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);<br />
<br />
GetObject(image, sizeof(BITMAP), &bm);<br />
<br />
hdcMem = CreateCompatibleDC(global_hdc);<br />
SelectObject(hdcMem, image);<br />
<br />
BitBlt(<br />
global_hdc,
x,y,
bm.bmWidth, bm.bmHeight,
hdcMem,
0,0,
SRCCOPY);
<br />
DeleteDC(hdcMem);<br />
DeleteObject((HBITMAP)image);<br />
ShowWindow(global_hwnd, SW_SHOW);<br />
}
all i need it to do is draw once and move around the screen with the rand() function. Any help would be great because this is not a essential task of the book but i like to know how to anything with the language i am learning. THANK YOU.
|
|
|
|
|
to do this, you need to make a copy of the image underneath the bitmap before you draw it. something like this:
1. find out where you want to draw the bitmap
2. make a copy of the background where the bitmap will go to a new bitmap, before you draw there. (create a new bitmap, use BitBlt to copy)
3. when you need to move the bitmap, draw the background copy from step 2 at the place you copied it from. then go to step 1.
to do this smoothly, you'll need to use a double-buffering technique, where you place replace the background and draw the new bitmap in one BitBlt to the main screen. otherwise, you could get a flicker effect.
i think there are articles on CP that discuss how to do double buffering.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
ok i understand what i need to do but how do i go about making a copy of the background to a bitmap. If i was programming in vb this would take me like 2 seconds but i want to learn c because i have always known and can tell now that its a more powerful language. I appreciate any help thank you.
|
|
|
|
|
making a copy of the background is just a BitBlt to an off-screen DC, using a CBitmap you've created specifically for that purpose.
but, this article[^] should help.
Cleek | Image Toolkits | Thumbnail maker
-- modified at 8:09 Wednesday 7th June, 2006
|
|
|
|
|
which function gets color setting of PC?
such as 256 color, 16 bits etc.
|
|
|
|
|
If you've got a screen device context, you can use GetDeviceCaps(BITSPIXEL)
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I'm having problems with my socket. Here is the scenario.
I have 2 network cards.
A. inet connection
B. Gigabit ethernet connected to network.
I'm trying to connect to an IP on card B. "1.2.3.4:18" for example.
My problem is that it is using network card A. and its not connecting properly because of this.
<br />
<br />
SOCKADDR_IN InternetAddr;<br />
InternetAddr.sin_family = AF_INET;<br />
InternetAddr.sin_addr.s_addr = htonl(inet_addr("1.2.3.4"));<br />
InternetAddr.sin_port = htons(18);<br />
<br />
Connection = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);<br />
connect(Connection, (SOCKADDR *)&InternetAddr, sizeof(InternetAddr);<br />
<br />
I create the socket fine... and it sends fine... just on the wrong network card.
Please HELP!!
|
|
|
|
|
signiture of the function is:
CreateDIBSection(HDC hdc,BITMAPINFO*pbf,..,void**ppBits..);
we must provide info for pbm to retrieve ppBits.
my question is:
how to get original BITMAPINFO and ppBits of the HDC?
are there other assistant functions to do that in general?
the HDC may not be memory DC, it may be PAINT DC whose HBITMAP size is 1x1.
the question is in general - not limited to memory DC.
|
|
|
|
|
GetObject()
have to access several API for complete BITMAPINFO. look MSDN
Kuphryn
|
|
|
|
|
I just told you in my post that GetObject() gets bitmap size of 1x1 for PAINT DC.
|
|
|
|
|
includeh10 wrote: how to get original BITMAPINFO and ppBits of the HDC?
DC's do not have those things.
you need to allocate and fill-in the BITMAPINFO object yourself. and the ppvBits parameter is an output parameter, that receives a pointer to the start of a buffer. after you call CreateDIBSection, you copy your DIB's pixels into the buffer where that pointer points:
<br />
void *ppvBits = NULL;<br />
hbm = CreateDIBSection(hDC,(LPBITMAPINFO)lpbi, DIB_RGB_COLORS, &ppvBits, NULL, 0);<br />
<br />
if (ppvBits!=NULL)<br />
{<br />
memcpy((BYTE *)ppvBits, (BYTE *)lpDIBBits, numberOfPixelBytes);<br />
}<br />
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
lpbi is [in].
my question is not about bits, but about how to get
numberOfPixelBytes and colors etc.
GetDIBits() can not help because HBITMAP size of PAINT DC is 1x1 pixels.
|
|
|
|
|
|
mate,
do not type reply before thinking.
|
|
|
|