|
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.
Nahitan
|
|
|
|
|
Ok, sounds like a design or cost problem.
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.
Hope this helps
/M
|
|
|
|
|
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.)
So, what is the correct way to do it?
TIA,
Bob
modified on Sunday, September 13, 2009 3:41 PM
|
|
|
|
|
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().
|
|
|
|
|
Member 4253145 wrote: 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.
Because the state of more than one item is being changed.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
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?
Any help is much appreciated!
Regards,
Kylur.
|
|
|
|
|
 here's the classic MSDN version:
BOOL DrawTransparentBitmap(HDC hdc,
HBITMAP hBitmap,
__int32 xStart,
__int32 yStart,
COLORREF cTransparentColor)
{
BITMAP bm;
COLORREF cColor;
HBITMAP bmAndBack, bmAndObject, bmAndMem, bmSave;
HBITMAP bmBackOld, bmObjectOld, bmMemOld, bmSaveOld, bmTempOld;
HDC hdcMem, hdcBack, hdcObject, hdcTemp, hdcSave;
POINT ptSize;
int iCaps = ::GetDeviceCaps(hdc, RASTERCAPS);
if ((iCaps & RC_BITBLT) != RC_BITBLT)
{
return FALSE;
}
if ((iCaps & RC_BITMAP64) != RC_BITMAP64)
{
return FALSE;
}
hdcTemp = CreateCompatibleDC(hdc);
if (hdcTemp==NULL)
{
return FALSE;
}
bmTempOld = (HBITMAP)SelectObject(hdcTemp, hBitmap);
if (GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm) != sizeof(BITMAP))
{
DeleteDC(hdcTemp);
return FALSE;
}
ptSize.x = bm.bmWidth;
ptSize.y = bm.bmHeight;
DPtoLP(hdcTemp, &ptSize, 1);
hdcBack = CreateCompatibleDC(hdc);
hdcObject = CreateCompatibleDC(hdc);
hdcMem = CreateCompatibleDC(hdc);
hdcSave = CreateCompatibleDC(hdc);
bmAndBack = CreateBitmap(ptSize.x, ptSize.y, 1, 1, NULL);
bmAndObject = CreateBitmap(ptSize.x, ptSize.y, 1, 1, NULL);
bmAndMem = CreateCompatibleBitmap(hdc, ptSize.x, ptSize.y);
bmSave = CreateCompatibleBitmap(hdc, ptSize.x, ptSize.y);
bmBackOld = (HBITMAP)SelectObject(hdcBack, bmAndBack);
bmObjectOld = (HBITMAP)SelectObject(hdcObject, bmAndObject);
bmMemOld = (HBITMAP)SelectObject(hdcMem, bmAndMem);
bmSaveOld = (HBITMAP)SelectObject(hdcSave, bmSave);
SetMapMode(hdcTemp, GetMapMode(hdc));
BitBlt(hdcSave, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0, SRCCOPY);
cColor = SetBkColor(hdcTemp, cTransparentColor);
BitBlt(hdcObject, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0,
SRCCOPY);
SetBkColor(hdcTemp, cColor);
BitBlt(hdcBack, 0, 0, ptSize.x, ptSize.y, hdcObject, 0, 0, NOTSRCCOPY);
BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdc, xStart, yStart, SRCCOPY);
BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdcObject, 0, 0, SRCAND);
BitBlt(hdcTemp, 0, 0, ptSize.x, ptSize.y, hdcBack, 0, 0, SRCAND);
BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0, SRCPAINT);
BitBlt(hdc, xStart, yStart, ptSize.x, ptSize.y, hdcMem, 0, 0, SRCCOPY);
BitBlt(hdcTemp, 0, 0, ptSize.x, ptSize.y, hdcSave, 0, 0, SRCCOPY);
DeleteObject(SelectObject(hdcBack, bmBackOld));
DeleteObject(SelectObject(hdcObject, bmObjectOld));
DeleteObject(SelectObject(hdcMem, bmMemOld));
DeleteObject(SelectObject(hdcSave, bmSaveOld));
SelectObject(hdcTemp, bmTempOld);
DeleteDC(hdcMem);
DeleteDC(hdcBack);
DeleteDC(hdcObject);
DeleteDC(hdcSave);
DeleteDC(hdcTemp);
return TRUE;
}
|
|
|
|
|
It's obsolete.
Use Shell : 4 lines of code (!)
|
|
|
|
|
And the four line would be?.....
(Or at least where should I look to find them myself?)
|
|
|
|
|
|
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.
|
|
|
|
|
|
This code copied from a beginners book produces 26 errors !!!!!
I think the main problem is stated in the subject anyone please help i'm only on page 17
#include <<iostream.>>;
int main( )
{
int number;
number = 100;
cout << "int number" << number << endl;
}
|
|
|
|
|
heh,try this
#include<iostream>
using namespace std;
int main()
{
int number;
number=100;
cout<<"Number is "<<number<<endl;
return 0;
}
|
|
|
|
|
Thanks for your reply I now get the error:
Info :Building...
Info :Compiling C:\Users\Gordon\Desktop\Source Code\CPP Source\variable.cpp
Error: IOSTREAM.h(25,2):Error directive: Must use C++ for the type iostream.
|
|
|
|
|
Try shutting down the application and run it again.
|
|
|
|
|
Still no joy I'm using Borland Studio 6 does that have a factor?
|
|
|
|
|
how are you compiling your code ? (which compiler, IDE, ...).
Me think you are using a C compiler instead of a C++ compiler.
This signature was proudly tested on animals.
|
|
|
|
|
Sounds like an ancient compiler - requires iostream.h instead of iostream
|
|
|
|
|
I do need to use iostream.h instead of just iostream in Borland studio 6 is that just a quirk of their system?
|
|
|
|
|
gordon3056 wrote: is that just a quirk of their system?
Nah - that's how it was being used before the C++ ISO Standard took place (in 1998). However, I do recommend using a more recent compiler.
|
|
|
|
|
im not sure about that.Im using codeblocks btw,quite ez to use ^_^
|
|
|
|
|
I think its a tribute to The Code Project members that I an absolute beginner can get any help at all. Thank you
|
|
|
|
|
Hello,
I am trying to use this control in a toolbar. For the most part the code works. However, I am running into this odd problem that I am getting partial text back when I call GetText.
The app requires that when I click a different button in the toolbar, I check the combo box and retrieve the text from it for processing. That is when this bug surfaces. The last character is getting truncated. If I retrieve the text in response to the Enter key handler for the combo box, I get the full text using the same GetText call.
Here is the code...most all of it is lifted from the samples.
CObList listButtons;
if (CMFCToolBar::GetCommandButtons(ID_EDT_FIND_NDC, listButtons) > 0)
{
for (POSITION posCombo = listButtons.GetHeadPosition();
pSrcCombo == NULL && posCombo != NULL; )
{
CMFCToolBarComboBoxButton* pCombo = DYNAMIC_DOWNCAST(CMFCToolBarComboBoxButton, listButtons.GetNext(posCombo));
if (pCombo != NULL) pSrcCombo = pCombo;
}
}
if (pSrcCombo != NULL)
{
ASSERT_VALID(pSrcCombo);
LPCTSTR lpszSelItem = pSrcCombo->GetText();
...
}
So if the combo box has the text '1234567890', I am getting back '123456789' in one case, and '1234567890' in another case, depending on whether I press the other button or press the Enter key.
Has anyone encountered this, and can someone suggest a solution?
Thanks for your time.
|
|
|
|
|