Thanks for your reply, I might not explained it properly but having all the devices send fast heartbeat means a lot of data traffic and pay for that and when you have like 1000 device and want to pay more than 5M per month or something like $15/month for GPRS usage is not acceptable by customers. so fast heartbeat is not a solution. I was/ am looking for a better way of examining the healthiness of the GPRS data trafic through UDP socket. Thanks for ideas in advanced.
Unfortunately, I see no other technical solution than the one mentioned before. The concept of a heartbeat is more or less the same regardless of using UDP or TCP. If peer A wants to know about the status/availability of peer B, it either has to receive a "message" from B in regular intervals (and therfor knows that peer B is alive) -or- when there is no regular traffic to piggyback the heartbeat then one of the peers has to initiate (additional) heartbeats in reasonable intervals. For example an IRC server uses regular ping/pong messages every few minutes to find out about the connection status of its chat clients.
Regarding the costs, at the end of the day a better service will cause more traffic. You could offer your customers maybe a cheap basic service and an advanced service with more features.
I am having trouble getting tooltips right for CTabCtrl when it has enough tabs that the spinner is up to scroll through the tabs.
If I use CTabCtrl::SetToolTips(), then a tab's tooltip stays with it, even when the tabs scroll (good). The problem is that it seems to take my tool ID (1, 2, ... N) as an index into the tabs -- and zero is not a valid ID (asserts in MFC), so I cannot have a tooltip for the first tab.
Alternatively, I can do the tooltips on my own -- the problem there is that I do not know how to tell when the tabs scroll so I can update the tooltip control's rects. WM_HSCROLL works for the spinner, but not if the scrolling happened because of a right- or left-arrow key.
I could set to supply the tooltip text each time, and on each request compare the cursor postion to the tab rect's, but that seems like a heavyweight kludge. (I could also go to multi-line tabs, but do not want to do that.)
I am using a CListCtrl control in may application, where i have 10 iteams in that control.
Now after receiving some input from user , i need to select a particular item from that list.
I have a code where after receiving users input , i am calling myCtrl.SetItemState( itemID, LVIS_SELECTED, LVIS_SELECTED ); to select respective item from that ctrl.
Now it is observed that after executing above line of code, afx_msg void OnSelchanged( NMHDR* pNMHDR, LRESULT* pResult ) is getting called multiple times.
Also when i tried to retrieve selected item in OnSelchanged method , by using ( GetFirstSelectedItemPosition() and GetNextSelectedItem() ), it gives different output every time.
Can you please explain,
i) why this OnSelchanged() method is getting called multiple times whenever myCtrl.SetItemState( itemID, LVIS_SELECTED, LVIS_SELECTED );line of code gets executed.
ii) Why i am getting different output ( id of item selected) after executing GetFirstSelectedItemPosition() and GetNextSelectedItem().
When you select an item in the list control, the previously selected item is deselected.
The OnSelChanged will be called twice here, once when the previous item is deselected and then when the new item is selected. This is what David mentioned in his reply.
It is not a good idea to call functions like GetFirstSelectedItemPosition and GetNextSelectedItem inside the OnSelChanged handler.
In-fact you don't need to.
It is already given to you in the NMLISTVIEW parameter of the handler.
You need to check the state of the uNewState member. if (LVIS_SELECTED & pNMLV->uNewState)
If the above condition is true, you can get the selected item in the iItem member.
«_Superman_» I love work. It gives me something to do between weekends.
I'm developing an application that allows the user to create a bitmap from portions of "n" other source bitmaps. For example, starting with three bitmaps (A, B, and C), the user could select the top third of A, the middle third of B and the bottom third of C and create destination bitmap D.
What I'd like to do is create a window that shows one of bitmap A, B, C.... (and has a dialog bar allowing selection of which one). A, B, and C are fully formed, that is, all pixels are defined. Bitmap D is undefined, that is, all pixels are (by default) white. I'd like to display D as a translucent bitmap on top of the selected source bitmap. It the user left-click+moves the mouse over the pair of bitmaps the pixels on A are copied up into D.
Once all desired pixels of A are copied upto D, the user would change A to B, D would now be displayed on top of B and the user could copied pixels from B upto D. And so on for all source bitmaps.
The undefined parts of D (ie the white pixels) I'd like to show as a "gray film", and the cursor would then be an "eraser" ie remove the "film" and allows the underlying bitmap to shine through.
In theory this is all fairly easy. BUT, I'm stymied on the simple part of how do I create and display the translucent bitmap D?
Attempts so far are:
1. create aDC_ with aBitmap_
2. create dDC_ with dBitmap_
3. create memDC_ with memBitmap_
4. memDC_->BitBlt(..., aDC_..., SRCCOPY)
5. memDC_->BitBlt(..., dDC_, ..., ?) <=== this is the translucent bitmap
6. pDC->BitBlt(..., memDC_..., SRCCOPY);
The question is how do a setup the DC_'s to get the translucency to work?
BOOL DrawTransparentBitmap(HDC hdc,
HBITMAP bmAndBack, bmAndObject, bmAndMem, bmSave; // lots of storage
HBITMAP bmBackOld, bmObjectOld, bmMemOld, bmSaveOld, bmTempOld;
HDC hdcMem, hdcBack, hdcObject, hdcTemp, hdcSave; // lots of dc's
int iCaps = ::GetDeviceCaps(hdc, RASTERCAPS);
if ((iCaps & RC_BITBLT) != RC_BITBLT)
if ((iCaps & RC_BITMAP64) != RC_BITMAP64)
hdcTemp = CreateCompatibleDC(hdc);
bmTempOld = (HBITMAP)SelectObject(hdcTemp, hBitmap); // Select the bitmapif (GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm) != sizeof(BITMAP))
ptSize.x = bm.bmWidth; // Get width of bitmap
ptSize.y = bm.bmHeight; // Get height of bitmap
DPtoLP(hdcTemp, &ptSize, 1); // Convert from device// to logical points// Create some DCs to hold temporary data.
hdcBack = CreateCompatibleDC(hdc);
hdcObject = CreateCompatibleDC(hdc);
hdcMem = CreateCompatibleDC(hdc);
hdcSave = CreateCompatibleDC(hdc);
// Create a bitmap for each DC. DCs are required for a number of// GDI functions.// Monochrome DC
bmAndBack = CreateBitmap(ptSize.x, ptSize.y, 1, 1, NULL);
// Monochrome DC
bmAndObject = CreateBitmap(ptSize.x, ptSize.y, 1, 1, NULL);
bmAndMem = CreateCompatibleBitmap(hdc, ptSize.x, ptSize.y);
bmSave = CreateCompatibleBitmap(hdc, ptSize.x, ptSize.y);
// Each DC must select a bitmap object to store pixel data.// (HBITMAP) Casts added by CDL, 3/26/96
bmBackOld = (HBITMAP)SelectObject(hdcBack, bmAndBack);
bmObjectOld = (HBITMAP)SelectObject(hdcObject, bmAndObject);
bmMemOld = (HBITMAP)SelectObject(hdcMem, bmAndMem);
bmSaveOld = (HBITMAP)SelectObject(hdcSave, bmSave);
// Set proper mapping mode.
// Save the bitmap sent here, because it will be overwritten.
BitBlt(hdcSave, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0, SRCCOPY);
// Set the background color of the source DC to the color.// contained in the parts of the bitmap that should be transparent
cColor = SetBkColor(hdcTemp, cTransparentColor);
// Create the object mask for the bitmap by performing a BitBlt// from the source bitmap to a monochrome bitmap.
BitBlt(hdcObject, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0,
// Set the background color of the source DC back to the original// color.
// Create the inverse of the object mask.
BitBlt(hdcBack, 0, 0, ptSize.x, ptSize.y, hdcObject, 0, 0, NOTSRCCOPY);
// Copy the background of the main DC to the destination.
BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdc, xStart, yStart, SRCCOPY);
// Mask out the places where the bitmap will be placed.
BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdcObject, 0, 0, SRCAND);
// Mask out the transparent colored pixels on the bitmap.
BitBlt(hdcTemp, 0, 0, ptSize.x, ptSize.y, hdcBack, 0, 0, SRCAND);
// XOR the bitmap with the background on the destination DC.
BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0, SRCPAINT);
// Copy the destination to the screen.
BitBlt(hdc, xStart, yStart, ptSize.x, ptSize.y, hdcMem, 0, 0, SRCCOPY);
// Place the original bitmap back into the bitmap sent here.
BitBlt(hdcTemp, 0, 0, ptSize.x, ptSize.y, hdcSave, 0, 0, SRCCOPY);
// Delete the memory bitmaps.
// Delete the memory DCs.
Hello, I need a library file or some program which is similar to bigint() class in the C++. bigint() class library in C++ is used to represnt big int numbers in the C++ programs but I needed such type of library in the C.