|
Anyone knows the equation(s) that can be used to transform a flat surface into a wave? (such as ocean waves, waterfalls, etc...) taking into account frequency, amplitude, perspective, turbulence, etc... Thanks for any help.
Henry P.
http://www.allersoft.com
|
|
|
|
|
Hi everyone,
I will just wanna ask, if who have a brilliant idea about this interesting question.
Sledge
|
|
|
|
|
Me thinks this is impossible because a word is just set of pixels. You could capture the pixels and do OCR and turn them back into a word. Of course if this is your app, then you are drawing the text and you know what a word is. I'm just talking about apps which aren't yours, which is what you asked.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Yes, you are right. The application that I will be capturing the text is not within my application. If you have any basic or advance OCR algorithms, can you give me?
Regards,
Sledge1978001
|
|
|
|
|
I'm afraid I've never done any work with OCR.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
how to use C++ to open the dicom data....
if u know the ans, pls share with me....
|
|
|
|
|
1.What 's wrong with my MouseProc hook?
LRESULT CALLBACK MouseProc(int nCode,WPARAM wParam,LPARAM lParam)
{
LPMOUSEHOOKSTRUCT pMouseHook=(MOUSEHOOKSTRUCT FAR *)lParam;
if (nCode>=0)
{
HWND glhTargetWnd=pMouseHook->hwnd;
HWND ParentWnd=glhTargetWnd;
while (ParentWnd !=NULL)
{
glhTargetWnd=ParentWnd;
ParentWnd=GetParent(glhTargetWnd);
}
if(glhTargetWnd!=glhPrevTarWnd)
{
char szClassName[40];
GetClassName(glhTargetWnd,szClassName,20);
if (stricmp(szClassName,"XLMAIN")==0)//Excel Main Window
{
switch(wParam)
{
case WM_RBUTTONUP:
case WM_RBUTTONDOWN:
//....
//Here I want stop the message to XLMAIN Window
//
strcat(szClassName,"You press right mouse button");
//Infact my program never go here when I click each mouse button,Why?
TRACE0(szClassName);
break;
case WM_LBUTTONUP:
case WM_LBUTTONDOWN:
strcat(szClassName,"You press left mouse butto");
//Infact my program never go here when I click each mouse button,Why
TRACE0(szClassName);
default:
AfxMessageBox("Mouse is in Excel Window");//program goes here
}
glhPrevTarWnd=glhTargetWnd;
}
SendMessage(glhDisplayWnd,WM_SETTEXT,0,(LPARAM)(LPCTSTR)szClassName);
//glhDisplayWnd-CEdit window HWND,This is just for test.
}
}
return CallNextHookEx(glhHook,nCode,wParam,lParam);
}
2.how to cancel special message to a special window
|
|
|
|
|
Well maybe if you show us your code we could help. That said I don't like the sound of what you are doing.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
It isn't obvious what glhPrevTarWnd does or where it is being set, so maybe you getting anything past that test. Also check what messages are getting past the stricmp(szClassName,"XLMAIN")==0 test. Finally try testing for WM_RBUTTONDOWN and WM_CONTEXTMENU. It is possible the app is capturing WM_BUTTONDOWN and you never get to see the WM_RBUTTONUP. You should also check all Win API functions succeed. eg. GetClassName().
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
i'm not getting any messages to my dialog proc created with DialogBox(...), i am setting my HINSTNANCE, parent window, and dialog proc. they are receiving WM_INITDIALOG, that is the only message i get as far as i know. the dialog is a child window, and that window is a popup window. any idea would could be wrong with it? the code is rather large and distributed (each dialog is created in a virtual function of a property class), but if you want i can post it
|
|
|
|
|
Have you verified with Spy++ the messages are going to the dialog?
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
they are being sent, but to my top level window (because the dialog is a child) which is not what i want. how i can make it send the messages to the dialog instead?
|
|
|
|
|
I have a dialog box with several CEdit controls inside of it that are created dynamically during runtime, that dialog box sometimes is hidden and sometimes is not. When the dialog box is hidden for the first time, the 'strings' in the CEdit controls are saved into a data structure that i've defined, when the dialog is shown again i read the stores values previously and write them into the CEdit controls but this time the text inside of it is not the expected but it is the previous that was stored in there. I think there are some problems with updates. Since i'm new to MFC probably i need to do something to keep the CEdit controls update the text correctly. Any tip ?
Thanks
|
|
|
|
|
There are several solutions. One solution is SetWindowText(). Another solution is to add a CString member variable that corresponds to the editbox. Update the variable as a string and call UpdateData(false) to update the actual edit control.
Kuphryn
|
|
|
|
|
The unusual thing that you are doing, is not actually initializing the dialog -- that is creating it each time. So the 'normal' stuff that MFC does to transfer data from CString's <--> CEdit's is not getting done.
I don't know the answer, but it has something to do with the DoDataExchange stuff that get's done when WM_INITDIALOG is handled. A possible hack would be to send your dialog the WM_INITDIALOG message??? (HACK ALERT!)
Just a thought...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
Santa Cruz Networks
|
|
|
|
|
My program has a virtual screen, many times larger than the real screen. In order to navigate on the virtual screen, I use scroll-bars. However I do not like that. I want, that when I move the cursor/mouse to the edge of my window, the window "pans" in the desired direction, and my cursor is re-located to the middle of my window.
I know, that this is against "the grain" of windows, because I would imprison the cursor inside my window until I exit my application.... but this is what I want.
Anybody...?
Thanks
Daniela
|
|
|
|
|
|
The basic approach to this is to SetCapture() on the window you want to stay in. Then scroll it when the mouse moves outside its boundaries. Remember to ReleaseCapture() when you are finished
|
|
|
|
|
Can someone please explain why my code isn't working???
I'm trying to send a raw UDP packet with a self constructed header.
I posted something like this earlier but i investigated the code since then and changed a bit cause it seemed to contain some bugs. BUT the problem remains the same, the code fails at runtime because the sendto() function returns 10049
WSAEADDRNOTAVAIL: Cannot assign requested address. This can also result from connect, sendto!!!, WSAConnect, WSAJoinLeaf, or WSASendTo when the remote address or port is not valid for a remote computer (for example, address or port 0).
Does this mean something might be wrong with my sin structure???? I don't understand, how can it be wrong, i mean, why would it even be USED as it is a raw packet and i constructed the header with the destination ip and port myself!!?? I really don't understand why it won't work, and its been bugging me for several days now so if anyone knows why it won't work, please let me know.
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 "172.27.2.15"
#define PORT 123
#define IP_DEST "192.168.200.9"
#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 + 20);
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+28,"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");
}
getch();
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 = (20);
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>
Thanks
Kuniva
--------------------------------------------
|
|
|
|
|
Kuniva wrote:
datagram[5000] = NULL;
I did only a cursory check so this is probably not your problem but was wondering what you were trying to do here. datagram is an array of 5000 but has elements 0 to 4999, so if you wanted to put a terminating '\0' you are overwriting the bounds of that array. Also, I don't think you can send a packet over ~1594 in size so I don't know why you would try to send 5000 bytes.
Probably a good idea to remove your strlen() call in the sendto(). BTW, you don't have to terminate your data with a trailing zero but I guess it could make it easier on the other side (recv side) if you knew you were handling strings. As you probably already know you would put the trailing zero after "Teste". Thus, the length in sendto() would be 5 or 6 (incl the terminating zero)
I don't know why you get the 10049 error. Perhaps, you are trying to access a reserved or dedicated port. If you are not, then I would choose a port number > 1023.
|
|
|
|
|
erm..
Well first of all thanks for taking a look. I can understand most of the comments but there's two things i don't seem to understand:
1.: Why get rid of strlen() in sendto()? I can understand that i need to replace it with sizeof() but the argument in sendto() requests the size of datagram, which would be the header + the data
2.: So obviously the second thing i don't understand is this:
"Thus, the length in sendto() would be 5 or 6 (incl the terminating zero)"
Isn't my header in there too? and did i not use strcpy(datagram+28,"Teste") ??? to put the "Teste" string behind the ip+udp header? Or am i missing something here?
I realise you only took a quick look, and the code is somewhat chaotic, but this didn't seem to make sense to me.
I'll also try using a different port number.
Thanks
Kuniva
--------------------------------------------
|
|
|
|
|
Well, I've never done raw before but in the past when I used sendto(), I always put the size of the data only. Search on this forum...within the last week or two somebody asked about how to do raw mode and somebody posted a link to a sample program on MSDN. This is where I downloaded this. Hope it helps:
#include <winsock2.h>
#include <windows.h>
#include <ws2tcpip.h>
#include <stdio.h>
#include <conio.h>
#pragma comment(lib, "ws2_32.lib")
#pragma pack(1)
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, 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_p;
unsigned short int ip_sum;
unsigned int ip_src;
unsigned int ip_dst;
};
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);
}
#define PORT 25
int main (void)
{
WSADATA wsd;
char datagram[4096];
int bOpt = 1;
if (WSAStartup(MAKEWORD(2,2), &wsd) != 0)
{
printf("WSAStartup() failed: %d\n", GetLastError());
return -1;
}
SOCKET s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
if (s == INVALID_SOCKET)
{
printf("WSASocket() failed: %d\n", WSAGetLastError());
return -1;
}
struct ipheader *iph = (struct ipheader *) datagram;
struct tcpheader *tcph = (struct tcpheader *) (datagram + sizeof (struct ipheader));
struct sockaddr_in sin;
sin.sin_family = AF_INET;
sin.sin_port = htons (PORT);
sin.sin_addr.s_addr = inet_addr ("2.3.4.5");
memset (datagram, 0, 4096);
iph->ip_hl = 5;
iph->ip_v = 4;
iph->ip_tos = 0;
iph->ip_len = sizeof (struct ipheader) + sizeof (struct tcpheader);
iph->ip_id = 1;
iph->ip_off = 0;
iph->ip_ttl = 255;
iph->ip_p = 6;
iph->ip_sum = 0;
iph->ip_src = inet_addr ("1.2.3.4");
iph->ip_dst = sin.sin_addr.s_addr;
tcph->th_sport = htons (1234);
tcph->th_dport = htons (PORT);
tcph->th_seq = rand();
tcph->th_ack = 0;
tcph->th_x2 = 0;
tcph->th_off = 5;
tcph->th_flags = 2;
tcph->th_win = htons(65535);
tcph->th_sum = 0;
tcph->th_urp = 0;
iph->ip_sum = checksum((unsigned short *)&iph, sizeof(ipheader) >> 1);
if (setsockopt(s, IPPROTO_IP, IP_HDRINCL, (char *)&bOpt, sizeof(bOpt)) == SOCKET_ERROR)
{
printf("setsockopt(IP_HDRINCL) failed: %d\n", WSAGetLastError());
return -1;
}
printf("Started sending of raw data. Hit any key to quit\n");
while (!kbhit())
{
if (sendto(s, datagram, 40, 0, (SOCKADDR *)&sin, sizeof(sin)) == SOCKET_ERROR)
{
printf("sendto() failed: %d\n", WSAGetLastError());
return -1;
}
printf(".");
Sleep(1000);
tcph->th_seq++;
}
return 0;
}
|
|
|
|
|
along with Johnny's great comments, one thing struck me.
Since your tcp/ip/udp headers are "raw" network data -- they should be packed? Or am I wrong?
#pragma pack(push,1)<br />
struct<br />
{<br />
BYTE x;<br />
BYTE y;<br />
};<br />
#pragma pack(pop)
As I recall, structure members are aligned on DWORD boundaries by default. That is, that a struct like the one above would have 3 bytes of unused data between x and y. You can verify by doing a sizeof() on your data.
Packing it forces the structure members to line up one directly following the next (no space between items).
When in doubt, I always force things to pack for creating network packet headers....
Does this make sense? Does this apply? Am I incorrect?
-p
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
Santa Cruz Networks
|
|
|
|
|
I am planning to create a small application that will utilize a database for managing persistant data.
I'd like to use MySQL as the database engine, but am having a difficult time figuring out how I could distribute the app. without requiring the user to have MySQL installed.
Any help at all would be appreciated in helping me figure out what needs to be done to make this a reality.
|
|
|
|
|
Don't tie your application to any database. Instead, have a requirement that the database be installed. Then have a little wizard or setup program that will request the userid and password for the database. Then use SQL statements to create the DB structure.
The only requirement is that your SQL statements work. I have created entire Access databases using SQL because all I had was the ODBC driver.
--
"The money power of the country will endeavor to prolong its rule by preying upon the prejudices of the people until all wealth is concentrated in a few hands and the Republic destroyed."
-- Abraham Lincoln
|
|
|
|
|