|
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
--------------------------------------------
|
|
|
|
|
Hello
I want to make a separator between tow buttons in toolbar!! how can i do it?
Best Regards
|
|
|
|
|
|
thank you very match
Best Regards
|
|
|
|
|
If I create a window, and I use the normal SetWindowsHook procedure like this:
<br />
SetWindowsHookEx(WH_CBT, (HOOKPROC)CBTProc, hInstance, NULL);<br />
It does work on self defined windowclasses but it doesn't seem to work with normal controls, like buttons and so on. How can I overrule this? If not possible, can I make a button using a selfdefined windowclass which calls the button procedure on it's turn?
LPCTSTR Dutch = TEXT("Double Dutch ");
|
|
|
|
|
I know in mfc application, we can get the path of exe from CWinApp. But how can i do the same thing in console exe without MFC? The reason i need this feature is some parameter file is store in the same directory as exe. Any idea to solve it?
|
|
|
|
|
|
How can I open a database and execute SQL requests without MFC classes (CDaoDatabase, CDaoRecordset...)? in other words: how people used to work with databases before the existance of MFC (the old times)?
Thank you in advance.
|
|
|
|
|
Maybe you should use the ODBC API directly from your app. There should be plenty of information on MSDN.
|
|
|
|
|
|
In the computer world, 1 = true and 0 = false,
but why do we return 0 to indicate it is
successful? For example,
int main()
{
// codes here
return 0; // to indicate successful
}
|
|
|
|
|
One of the reasons is because a lot of the time we want to know what went wrong. We can't have lots of different zeros, so we just let 0 be success, and have any non-zero value meaning failure. This becomes just as simple a test, except that we can get more detail if required by checking for a particular non-zero value - if the program in question returns different values for different errors.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
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"
|
|
|
|
|
There are two ways of looking at return values. One is succeeded/failed, and the boolean type is perfect for that. So true (1) indicates success, false (0) indicates failure. The other way is using a set of numbers with predefined meanings. In this case, success does not have to be 0, or 1, or 6000, or anything really. 0 is the first number, and it just happened to be assigned the meaning success (ERROR_SUCCESS ).
--Mike--
Latest blog entry: *drool* (Alyson) [May 10]
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|