|
Hiya just wondering how I can make a pie chart in MFC??
Can't seem to find a class that I can use. Using Visual C++.NET.
Thanks,
grahamoj.
|
|
|
|
|
One solution is to do your own drawing. Otherwise, looking at CodeProject and CodeGuru.
Kuphryn
|
|
|
|
|
CDC::Pie()
Look it up in MSDN, it includes a small example.
Trust in the code Luke. Yea right!
|
|
|
|
|
yes or not, why?
includeh10
|
|
|
|
|
Hi,
In a dialog box a have a RichEditCtrl. I put a link in this richeditctrl like this.
CHARFORMAT2 userFont;
userFont.dwEffects = CFE_LINK;
descText->SetSel(0,descText->GetWindowTextLength());
descText->SetSelectionCharFormat(userFont);
descText->ReplaceSel("Click here");
How can I trap the click on that link? I've tried with
ON_NOTIFY(NM_CLICK,IDC_COMMAND,DoOnLink)
[IDC_COMMAND is the id of the RichEditCtrl]
but it doesn't execute the DoOnLink function.
Any ideas?
Thanks
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
|
Hello there,
I am trying to build a custom button in win32 c++ and trying to utilize the WM_MOUSEHOVER message in the Window Procedure. But when i try to compile the code it says WM_MOUSEHOVER is undeclared and TRACKMOUSEEVENT is missing!!! I have not defined WIN32_LEAN_AND_MEAN or any such thing. I am using VC++ 6.0 Pro. Please help me out and thankx in advance.
-Tareq
|
|
|
|
|
I guess you need to download the latest Platform SDK. My old MSDN Library (from 2000) doesn't know the message as well, but it works with the latest Platform SDK nonetheless.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I think youre right. I have tried the same code with the new mingw compiler and it works like a charm. but the only problem is debugging so i guess i have to work with it until i complete downloading the platform sdk (300MB+) on my dialup line . Thankx man.
-Tareq
|
|
|
|
|
Hi.
I'm having problems using WS_EX_NOACTIVE flag for my CreateWindowEx.
I have this line:
MessageWindow = CreateWindowEx (WS_EX_NOACTIVATE| WS_EX_APPWINDOW,"MainWindow",......)
But I get an error:
'WS_EX_NOACTIVATE' : undeclared identifier
WS_EX_APPWINDOW is known, but not WS_EX_NOACTIVETE.
Is it just me or is this a bug?
I'm using VC6.0
Thanks alot
|
|
|
|
|
See my post above. Download the latest Platform SDK, it should work then
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
How to disable an initial selection in CEdit?
The CEdit control is only control in dialog and it's appears to be selected every time dialog is created. I don't need this.
Of course I can use SetSel but is there any smater way to do that?
|
|
|
|
|
Disable the control's default property in resource editor.
Kuphryn
|
|
|
|
|
|
|
Hello,
assume I have an array with dimensions 6x5 = 30 elements. The normal way to map an index value (ranging from 0 to 30) is this:
x = i mod 6, y = i div 6 .
But now I want to access this array like a snail, so for increasing 'i' the elements should more and more near the center.
<br />
00 01 02 03 04 05<br />
17 18 19 20 21 06<br />
16 27 28 29 22 07<br />
15 26 25 24 23 08<br />
14 13 12 11 10 09<br />
The numbers in this table are the index values 'i'.
So for i=18, the element accessed should be x=1,y=1.
For i=29, x=3,y=2
For i=12, x=2,y=4.
Do you know a formula or fast algorithm to accomplish this? It should work for different array dimensions (so lookup tables aren't allowed...).
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
Dominik Reichl wrote:
It should work for different array dimensions (so lookup tables aren't allowed...).
Use std::vector or std::list.
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Have you got whats my question???
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
Are you just looking for a way to access the information stored in the array? Not sure I understood the question.
-Nick Parker
|
|
|
|
|
Not only access, I want to access it in a special order.
If you translate index values to x and y coordinates of an array, you normally do this using the mod and div stuff. But I want to access the elements like a snail, so for increasing index value we should get more and more to the center of the array (as in the table I posted).
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
Hi, i found this code somewhere to open a raw socket under WIN XP and to send a packet with your own TCP/UDP header. The author posted it on a forum because the sendto() function failed at runtime. Someone then modified the code slightly (replaced sizeof() in sendto() to strlen()) and for them it worked, but i still get the same error. Here's the code:
<code>
#pragma comment( lib, "Ws2_32.lib" )
#define WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#include <windows.h>
#include <ws2tcpip.h>
#include <stdio.h>
#include <conio.h>
#define IP "192.168.200.18"
#define PORT 123
#define IP_DEST "192.168.200.19"
#define PORT_DEST 123
#define SIO_RCVALL _WSAIOW(IOC_VENDOR,1)
#define MAX_ADDR_LEN 16
#define MAX_HOSTNAME_LAN 255
USHORT checksum(USHORT *buffer, int size);
void checkPacket(char * pacote);
struct tcpheader {
unsigned short int th_sport;
unsigned short int th_dport;
unsigned int th_seq;
unsigned int th_ack;
unsigned char th_x2:4;
unsigned char th_off:4;
unsigned char th_flags;
unsigned short int th_win;
unsigned short int th_sum;
unsigned short int th_urp;
};
struct ipheader {
unsigned char ip_hl:4, ip_v:4;
unsigned char ip_tos;
unsigned short int ip_len;
unsigned short int ip_id;
unsigned short int ip_off;
unsigned char ip_ttl;
unsigned char ip_proto;
unsigned short int ip_sum;
unsigned int ip_src;
unsigned int ip_dst;
};
struct udpheader {
unsigned short int uh_sport;
unsigned short int uh_dport;
unsigned short int uh_len;
unsigned short int uh_sum;
};
int main (void)
{
WSADATA wsd;
char datagram[5000];
unsigned int bOpt=1;
if (WSAStartup(MAKEWORD(2,2), &wsd) != 0){
printf("WSAStartup() failed: %d\n", GetLastError());
return -1;
}
SOCKET s = WSASocket(AF_INET, SOCK_RAW, IPPROTO_UDP, NULL, 0,0);
if (s == INVALID_SOCKET){
printf("WSASocket() failed: %d\n", WSAGetLastError());
return -1;
}
if (setsockopt(s, IPPROTO_IP, IP_HDRINCL, (char *)&bOpt, sizeof(bOpt)) == SOCKET_ERROR){
printf("setsockopt(IP_HDRINCL) failed: %d\n", WSAGetLastError());
return -1;
}
struct ipheader *iph = (struct ipheader *) datagram;
struct udpheader *udph = (struct udpheader *) (datagram + (4*4));
struct sockaddr_in sin;
sin.sin_family = AF_INET;
sin.sin_port = htons (PORT_DEST);
sin.sin_addr.s_addr = inet_addr (IP_DEST);
memset (datagram, 0, sizeof(datagram));
iph->ip_hl = 5;
iph->ip_v = 4;
iph->ip_tos = 0;
iph->ip_len = sizeof (struct ipheader) + sizeof (struct udpheader);
iph->ip_id = 1;
iph->ip_off = 0;
iph->ip_ttl = 100;
iph->ip_proto = 17;
iph->ip_sum = 0;
iph->ip_src = inet_addr(IP);
iph->ip_dst = inet_addr(IP_DEST);
udph->uh_sport = htons (PORT);
udph->uh_dport = htons (PORT_DEST);
udph->uh_len = sizeof (struct ipheader) + sizeof (struct udpheader);
udph->uh_sum = 0;
strcpy(datagram,"Teste");
datagram[5000] = NULL;
iph->ip_sum = checksum((unsigned short *)&iph, sizeof(ipheader));
udph->uh_sum = checksum((unsigned short *)&udph, sizeof(udpheader));
checkPacket(datagram);
if (sendto(s, datagram, strlen(datagram), 0, (SOCKADDR *)&sin, sizeof(sin)) == SOCKET_ERROR)
{
printf("sendto() failed: %d\n", WSAGetLastError());
return -1;
}
else{
printf("OK\n");
}
if (sendto(s, datagram, strlen(datagram), 0, (SOCKADDR *)&sin, sizeof(sin)) == SOCKET_ERROR)
{
printf("sendto() failed: %d\n", WSAGetLastError());
return -1;
}
else{
printf("NOPE\n");
}
return 0;
}
USHORT checksum(USHORT *buffer, int size)
{
unsigned long cksum=0;
while (size > 1)
{
cksum += *buffer++;
size -= sizeof(USHORT);
}
if (size)
{
cksum += *(UCHAR*)buffer;
}
cksum = (cksum >> 16) + (cksum & 0xffff);
cksum += (cksum >>16);
return (USHORT)(~cksum);
}
void checkPacket(char * buff)
{
ipheader* pIpheader;
tcpheader* pTcpheader;
udpheader* pUdpheader;
SOCKADDR_IN saSource, saDest;
int iNextheader;
char * packetData;
pIpheader = (ipheader *) buff;
printf("IP Header \n");
printf("IHL: %d\n",(int)pIpheader->ip_hl);
printf("VERSION: %d\n",pIpheader->ip_v);
printf("TYPE OF SERVICE: %d\n",(int)pIpheader->ip_tos);
printf("TOTAL LENGTH: %d\n",pIpheader->ip_len);
printf("IDENTIFICATION: %d\n",pIpheader->ip_id);
printf("FRAGMENT OFFSET: %d\n",pIpheader->ip_off);
printf("TTL: %d\n",(int)pIpheader->ip_ttl);
printf("PROTOCOL: %d\n", (int)pIpheader->ip_proto);
printf("CHECKSUM: %d\n",pIpheader->ip_sum);
saSource.sin_addr.s_addr = pIpheader->ip_src;
printf("SOURCE ADDRESS: %s\n",inet_ntoa(saSource.sin_addr));
saDest.sin_addr.s_addr = pIpheader->ip_dst;
printf("DESTINATION ADDRESS: %s\n",inet_ntoa(saDest.sin_addr));
iNextheader = (pIpheader->ip_hl * 4);
if ((int)pIpheader->ip_proto == 6)
{
pTcpheader = (tcpheader *) (buff + iNextheader);
printf("\nTCP Header\n");
saSource.sin_port = pTcpheader->th_sport;
printf ("SOURCE PORT: %d\n", htons(saSource.sin_port));
saDest.sin_port = pTcpheader->th_dport;
printf ("DESTINATION PORT: %d\n", htons(saDest.sin_port));
printf ("SEQUENCE: %d\n", pTcpheader->th_seq);
printf ("ACK: %d\n", pTcpheader->th_ack);
printf ("X2: %d\n", (int)pTcpheader->th_x2);
printf ("OFF SET: %d\n", (int)pTcpheader->th_off);
printf ("FLAGS: %d\n", (int)pTcpheader->th_flags);
printf ("WINDOW: %d\n", pTcpheader->th_win);
printf ("CHECKSUM: %d\n", pTcpheader->th_sum);
printf ("URP: %d\n", pTcpheader->th_urp);
printf("\nDATA\n");
iNextheader = (pIpheader->ip_hl * 4 + sizeof(tcpheader));
packetData = (char *) (buff + iNextheader);
printf ("DATA: %s\n", packetData);
}
if ((int)pIpheader->ip_proto == 17)
{
printf("\nUDP Header\n");
pUdpheader = (udpheader *) (buff + iNextheader);
saSource.sin_port = pUdpheader->uh_sport;
printf ("SOURCE PORT: %d\n", htons(saSource.sin_port));
saDest.sin_port = pUdpheader->uh_dport;
printf ("DESTINATION PORT: %d\n", htons(saDest.sin_port));
printf ("LEN: %d\n", pUdpheader->uh_len);
printf ("CHECKSUM: %d\n", pUdpheader->uh_sum);
printf("\nDATA\n");
iNextheader = (pIpheader->ip_hl * 4 + sizeof(udpheader));
packetData = (char *) (buff + iNextheader);
printf ("DATA: %s\n", packetData);
}
getch();
}
</code>
Anyone know whats wrong here?
A possible clue might be: When the program runs and it displays all the info, for destination address it says "0.123.0.123" and i don't think thats right...
Also sendto() returns 10049, this is something to do with an address-not-available-error.
Thanks
Kuniva
--------------------------------------------
|
|
|
|
|
|
|
Hi y'all!
I have create a list view control which has check boxes!
How can I make the check boxes disabled inside the list view control, and how can I make transparent the frame which is around of the check mark?
Thanks for any answer!
|
|
|
|
|
use:
ListView_SetItemState ()
look for its parameters on the msdn library:
href="http://msdn.microsoft.com">msdn.microsoft.com[^]
Kuniva
--------------------------------------------
|
|
|
|
|