|
Now there is some errors in my code, but it's late now and I have to go to bed!
But can you tell me how to do this:
// dir_bcast_addr is a u_long and is wron type to fit..
bcast.sin_addr.s_addr = inet_addr(dir_bcast_addr);
int main()
{
WSAData wsaData;
int nCode;
if ((nCode = WSAStartup(MAKEWORD(2, 0), &wsaData)) != 0)
{
cout << "Ett fel inträffades när Winsock skulle startas, felkod " << nCode << "." << endl;
return 1;
}
SOCKET s;
BOOL bBroadcast;
char *sMsg = "This is a test";
SOCKADDR_IN bcast;
s = WSASocket(AF_INET, SOCK_DGRAM, 0, NULL, 0, WSA_FLAG_OVERLAPPED);
bBroadcast = TRUE;
setsockopt(s, SOL_SOCKET, SO_BROADCAST, (char *)&bBroadcast, sizeof(BOOL));
u_long host_addr = inet_addr("192.169.244.152");
u_long net_mask = inet_addr("255.255.255.128");
u_long net_addr = host_addr & net_mask;
u_long dir_bcast_addr = net_addr | (~net_mask);
bcast.sin_family = AF_INET;
bcast.sin_addr.s_addr = inet_addr(dir_bcast_addr);
bcast.sin_port = htons(5150);
sendto(s, sMsg, strlen(sMsg), 0, (SOCKADDR *)&bcast, sizeof(bcast));
while(TRUE)
{
char* buffer = new char[1024];
SOCKADDR_IN sender;
int sos = sizeof(sender);
int ret = recvfrom(s, buffer, sizeof(buffer), MSG_OOB, (SOCKADDR*)&sender, &sos);
if (ret == SOCKET_ERROR)
{
printf("recvfrom() failed; %d\n", WSAGetLastError());
break;
}
else if (ret == 0)
{
break;
}
else
{
buffer[ret] = '\0';
printf("[%s] sent me: '%s'\n", inet_ntoa(sender.sin_addr), buffer);
}
delete [] buffer;
}
closesocket(s);
WSACleanup();
return 0;
}
The error code is 10045 and it means that the function call or something is nott allowed!!???
Now I have to go and sleep!
See ya to morrow!
Rickard Andersson@Suza Computing
ICQ#: 50302279 (Add me!)
E-mail: nikado@pc.nu
I'm from the winter country SWEDEN!
|
|
|
|
|
I have been working on double buffering my CListView for the past few days... After this bit of code below, my list is now flicker free. The only problem I am having is that my Header wasn't being drawn.. When I add my code to draw the Header my items are shifted down for example.. when I add a item to row 1 its drawn in row 2 (row 1 appears empty) so if you click the mouse on the empty row 1 it highlights row 2, and so on.. if I exclude the code for the Header all the items are drawn correctly.
Any ideas on what I am doing wrong?
void CMyListView::OnPaint()
{
CRect rc;
CRect rcWnd;
CRect rcH;
CPaintDC dc(this);
CDC MemoryDC;
CBitmap Bitmap;
CBrush Brush;
GetParent()->GetClientRect(&rc);
if (rc.Size() == CSize(0,0))
return;
GetParent()->GetWindowRect(&rcWnd);
CHeaderCtrl* pHC = (CHeaderCtrl*)(GetListCtrl().GetDlgItem(0));
if(pHC != NULL)
{
pHC->GetItemRect(0,&rcH);
rc.top += rcH.bottom;
}
int rcWndW = rcWnd.Width(), rcWndH = rcWnd.Height();
TRACE("%d %d", rcWndW, rcWndH);
MemoryDC.CreateCompatibleDC(&dc);
Bitmap.CreateCompatibleBitmap(&dc, rcWndW, rcWndH);
CBitmap *pOldBitmap = MemoryDC.SelectObject(&Bitmap);
Brush.CreateSolidBrush(dc.GetBkColor());
MemoryDC.FillRect(&CRect(0,0, rcWndW,rcWndH), &Brush);
Print(&MemoryDC, PRF_CLIENT);
Print(&MemoryDC,PRF_OWNED);
CRect rcDraw = rc - rc.TopLeft();
dc.BitBlt(rc.left,rc.top, rc.Width(),rc.Height(), &MemoryDC, rcDraw.left,rcDraw.top, SRCCOPY);
MemoryDC.SelectObject(pOldBitmap);
}
|
|
|
|
|
RobJones wrote:
if I exclude the code for the Header all the items are drawn correctly.
But the header isn't? I wouldn't think you'd have to allow for it, really.
In any case, this line:
CRect rcDraw = rc - rc.TopLeft();
appears to be doubling the offset for rcDraw , probably not what you really want (all drawing done by Print() assumes client coodinates AFAIK, so the top of the client area is drawn at (0,0)).
--------
This is what we've waited for
This is it boys, this is War! --Shog9 --
|
|
|
|
|
I remarked the line you suggested and set the following.. its still doing the same thing .
dc.BitBlt(rc.left,rc.top, rc.Width(),rc.Height(), &MemoryDC, 0,0, SRCCOPY);
Could it be that i am some how not including the header in both the dc's?
Im at home so its showing the post as Anonymous.
|
|
|
|
|
Anonymous wrote:
Could it be that i am some how not including the header in both the dc's?
Possibly. But, rc.top is not going to be 0 either; it will be the height of the header. The line should read:
dc.BitBlt(rc.left,rc.top, rc.Width(),rc.Height(), &MemoryDC, rc.left,rc.top, SRCCOPY);
I'm curious as i've never tried doing this: is the header actually drawn into the buffer? Or does it get painted separately.
Good Luck
--------
This is what we've waited for
This is it boys, this is War! --Shog9 --
|
|
|
|
|
You Are the MAN!!
Thanks!
Rob
|
|
|
|
|
I'm using MAPIAddress() to allow selection of addresses. I'd like to set the default button as To/Cc/Bcc depending on which one the user is looking to add; does anyone know of a (preferably clean) way to accomplish this?
--------
This is what we've waited for
This is it boys, this is War! --Shog9 --
|
|
|
|
|
arg.. any help would be much appreciated..
i have a function called PopulateTree() which is supposed to remove all items currently in the tree, and repopulate it.
the problem is that everytime i call DeleteAllItems() and then add more items the new items never show up. ex:
m_tcReports.DeleteAllItems();
HTREEITEM hDoc = m_tcReports.InsertItem("wtf", NULL, TVI_SORT);
if i remove the DeleteAllItems() call then it will add the items everytime i call the function causing multiple copies of the same item.. but at least it adds the items.
is there something i have to do between DeleteAllItems() and adding a new item? ive tried Invalidate(), but that was to no avail..
also i've noticed that my message handler below always gets called 2 times in a row, any idea why?
ON_NOTIFY(DTN_DATETIMECHANGE, IDC_PERIODBEGIN, OnDtnDatetimechangePeriodbegin)
plz help this newbie out friendly ppl have a good weekend!
-dz
|
|
|
|
|
I think you need to do use TVI_ROOT instead of NULL in your call to InsertItem() .
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
thanks for the suggestion, but it still doesn't work.. i have tried to just delete the items one at a time in a loop instead of using deleteallitems() and then adding my items, but they still don't show up.. if i get rid of the deleteallitems() call they do show up.. i just don't get it.
-dz
|
|
|
|
|
The buttons with mnemonic could be acted pressing ALT+CHAR. But, sometimes I can press only the CHAR and the button is acted.
Anyone knows how solve this problem ?
Thanks,
Cristiano.
|
|
|
|
|
It's not a problem - it's normal behavior.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
But it can be a unwished behavior. To call any menus's function you must press ALT to act the mnemonics and then press another key to act the menu's function.
Is there any configuration or way to avoid act the function without press ALT ?
Thanks,
Cristiano.
|
|
|
|
|
[Intentionally posted in the VC++ forum instead of the Lounge]
Have you used (or do you use) QT to develop Win/Unix GUI apps? If so, I'd be grateful for your comments. Some of us are considering using QT at work, where cost is not an issue, but performance, ease of use, and good tech support is. Our apps are used primarily by hardware engineers, and the types of GUIs we build have a lot of graphical displays.
Thanks,
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Is there some way to programmatically set a system environment variable? SetEnvironmentVariable() only sets it for the current process... I need to "permanently" set one.
Any ideas?
J
"I am wise enough to therefore not spout my ill informed opinion as if it were remotely related to fact." - Christian Graus
|
|
|
|
|
Arrrr. Nevermind... You just set the values into the registry under HKEY_CURRENT_USER\Environment.
J
"I am wise enough to therefore not spout my ill informed opinion as if it were remotely related to fact." - Christian Graus
|
|
|
|
|
ANyone knows how to change the status bar height? There seems to be no mention of it.
Thanks in advance!!
|
|
|
|
|
Try adjusting your StatusBar height by SetWindowPos or MoveWindow...
// pSB is your Status Bar
CStatusBar* pSB = GetMessageBar();
pSB->SetWindowPos(...)
// OR
pSB->MoveWindow(...);
Mike M
WinInsider.com
|
|
|
|
|
The RGB function takes 8 bits each for Red, Green & Blue - making it a total of 24 bits. So, how does one write a program that would exploit the full 32 bit support of any decent graphics card?
Thanks in advance.
|
|
|
|
|
Your video card will still only support an 8 bit channel for Red Green and Blue, however it can then hold an alpha channel that can be used to hold other data, for transparent, or alpha belnding, for instance.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
GDI doesn't really support the 4th channel (except for a function or two in Win2K and XP). GDI+, does support the alpha channel, though. Take a look at the GDI+ tutorials on this site.
-c
ABSURDITY:
A statement or belief manifestly inconsistent with one's own opinion.
|
|
|
|
|
More advanced color formats would probably require DirectX or OpenGL.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
"32-bit" graphics cards are by and large just 24 bits stuffed into 32 bits. Why? Because it's faster to move 32-bit aligned data than 24-bit aligned data.
If they use the high 8 bits for anything, it's for transparency information, and that's not used on the primary surface anyway, only for textures and blitted surfaces.
I wrote an article on 16-bit and 32-bit graphics for Windows Developers Journal; it's here.
--
Tim
Tim Lesher <tim@lesher.ws>
http://www.lesher.ws
|
|
|
|
|
When you look at 3d programming, you might have 8R,8G,8B,8Z where the Z is the Z-depth of the pixel. This would be the frame buffer.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Greetings:
I have an application using CHTMLView which creates multiple HTML files based on user input. I have a print option but I want to be able to print ALL html files in a directory, not just the currently viewed HTML file. Is there any predefined class / function that will accept an HTML file and print it silently (no dialog box) in the background?
Thanks in advance for any info.
|
|
|
|
|