|
my wish is to find out wich file was used to start the program by dragging the icon of the file onto the unopened program icon. I would also like to be able to set the file extenshion to open the file using this program so the user can double click on a file with the right extenshion and start the program with that file loaded into it. I do not know how to make DragQueryFile() tell me wich file was used to start the program.
The Drag and Drop onto the open program window works great but I have not noticed that it sends any information about a file that was draged onto the unopened program icon in windows explorer, or about wich program was double clicked to start this program. I suspect that this is because DragAcceptFiles is not called untill 'SetupWindow()'
IF there is a better place to put DragAcceptFiles that would let the program find out this information it would be much easyer to do.
|
|
|
|
|
I have used the following tutorials to get a window on the screen.
http://www.zeuscmd.com/tutorials/win32/05-CreatingWindows.php
This is fine as the person writing it give pretty good explainations of what he does.
I have been unable to fine out how to put a button onto this screen as i cannot find and decent guides for this. Microsofts documentation is quite horrid, poorly orgainized and spits huge reams of code at you with little in the way of commenting.
Look at the java documentation for how it should be done tbh.
Now that mini rant is over this is my code that i copied from MSDN for putting a button on the screen.
<br />
hwndButton = CreateWindow( <br />
"BUTTON",
"Do Something",
WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
<br />
10,
10,
130,
20,
hwnd,
NULL,
(HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), <br />
NULL);
It does just that and its is one of the better commented examples and i have put two buttons on the screen.
What i cannot work out is how to identify the buttons when the message handles method is called.
this is coded as follows:
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)<br />
{<br />
switch(msg)<br />
{<br />
case WM_CLOSE :<br />
DestroyWindow(hwnd);<br />
break;<br />
<br />
case WM_DESTROY :<br />
PostQuitMessage(0);<br />
break;<br />
case WM_KEYDOWN:<br />
if(wParam == 'U'){<br />
MessageBox(NULL, "U Pressed", "U", MB_OK);<br />
}<br />
break;<br />
case WM_KEYUP:<br />
if(wParam == 'L'){<br />
MessageBox(NULL, "L Released", "L", MB_OK);<br />
}<br />
<br />
case BN_CLICKED:<br />
if(true)
MessageBox(NULL, "left ", "L", MB_OK);<br />
else<br />
MessageBox(NULL, "right ", "L", MB_OK);<br />
}<br />
return DefWindowProc(hwnd, msg, wParam, lParam);<br />
}
Anyone have any ideas? or any links to decent guides to win32 programming? (which don't just tell you have to get visual studio to generate the code for you)
|
|
|
|
|
gunner_uk2000 wrote: if(true) //have no idea what to put in here to work out which button was press.
if (hwndButton == hwnd)
...
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
That does not work, as it returns false when the hwndButton was clicked.
It also generate a compiler warning.
I i understand correctly hwndButton is a handle to the button, and hwnd is a handle to the window, so i don't see how checking if they are equal (which they will not be) will determin which button was pressed.
Correct me if i'm wrong.
|
|
|
|
|
gunner_uk2000 wrote: I i understand correctly hwndButton is a handle to the button, and hwnd is a handle to the window...
A button is a window.
The ninth argument to CreateWindow() is supposed to be the ID associated with the button control. You're using NULL . When a control generates a message, it is sent to the parent window. Processed messages are typically not sent to DefWindowProc() .
You should have:
hwndButton = CreateWindow(..., (HWND) MY_BUTTON, ...);
...
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_COMMAND:
if (LOWORD(wParam) == MY_BUTTON)
MessageBox();
return 0;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
When you create the button, set the hMenu parameter of CreateWindow to some resource ID such as IDC_MYBUTTON1. Define a value for this constant in your resource.h header file or some other place you want. Then in WndProc, switch the low-word of wParam which sends you the ID of the message source as
case WM_COMMAN:<br />
switch(LOWORD(wParam))<br />
{<br />
case IDC_MYBUTTON1:<br />
<br />
case IDC_MYBUTTON2:<br />
Enjoy...!
|
|
|
|
|
hi
I am programming for windows ce, and I need to know how to change a file type association using c++, what functions should I call to change the program that opens a specific file type (eg: .mp3)???
Thanks alot
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
Hi guys
I have been trying to make an app that gets the arra input from the user for ex:
I have made a variable for an edit box and named it BYTE m_bytes then i make another edit box and add the variable BYTE m_arrayinput thne i make a function like this:
void whatever()<br />
{<br />
UpdateData(true);<br />
<br />
BYTE myarray[m_bytes] = {m_arrayinput};<br />
}
now what i want to do with this code is to for example the user enters:
Bytes: 2<br />
<br />
Array Input: 0x60, 0x90
then i want the function to interpret it as:
void whatever()<br />
{<br />
UpdateData(true);<br />
<br />
BYTE myarray[2] = {0x60, 0x90};<br />
}
but this code does not work and i havnt got a clue of how to make it work so could someone please help me?
Thanks in advance
Cyclone
|
|
|
|
|
Cyclone02 wrote: BYTE myarray[2] = {0x60, 0x90};
This won't work that way. The CEdit data is a string, so you will have to parse that string and assign it to each element in the array.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Cyclone02 wrote: I have made a variable for an edit box and named it BYTE m_bytes...
You should be using a CEdit member variable for an edit control.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
for both of the variables? or just the bytes one?
|
|
|
|
|
For the one associated with the edit control. That way all you have to do is call SetWindowText() or GetWindowText() (into a CString object).
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
i tried doing that but it doesnt work i made a variable called CEdit m_bytes then i did this to the array:
Array[m_bytes] = {m_patch};
but all i got were a lot of errors
|
|
|
|
|
I want to save some file to harddisk such as C:\\Data\\Mydata.txt and then I want to call Window Explorer to open at the page" C:\\Data" automatically.
Anybody know, how to write the code for this issue.
|
|
|
|
|
::ShellExecute(NULL, "open", "C:\\Data", NULL, NULL, SW_SHOW);
|
|
|
|
|
Hello,
how can I set the focus to my SDI-applications toplevel window?
Problem: I have an application. The main dialog creates dynamically a subdialog which is displayed and has the focus. This subdialog creates and executes a thread. This thread creates also dynamically a (error-)dialog which is closed by buttonclick or automatically after some seconds. After the thread created subdialogs closes, I want to have back the focus on my applications top level window, which is the window who creates the thread. Til now, the main dialog receives the focus.
Any ideas?
Thanks
Juergen
-- modified at 10:55 Thursday 21st September, 2006
|
|
|
|
|
Just changed a few #defines into enum, and now getting compiler errors. How are enum types compared?
typedef enum tile_from_t
{
NORTH=0,EAST,SOUTH,WEST
} TILEFROM, SEAT, *LPSEAT;
bool cTiles::VerifySeat( const LPSEAT sSeat )
{
switch ( m_sNumPlayers )
{
case 2:
if ( sSeat == NORTH || sSeat == SOUTH )
return true;
case 3:
if ( sSeat >= EAST && sSeat <= WEST )
return true;
case 4:
if ( sSeat >= NORTH && sSeat <= WEST )
return true;
default:
return false;
}
}
|
|
|
|
|
waldermort wrote: bool cTiles::VerifySeat( const LPSEAT sSeat )
waldermort wrote: if ( sSeat == NORTH || sSeat == SOUTH )
You are comparing the pointer to the enum constants here. You can avoid this by just declaring the method as:
bool cTiles::VerifySeat(SEAT sSeat)
Using a const-reference or pointer for this method doesn't gain you anything.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Doh!!
Another question if I may.
Is it possible to increase the enum type? In my previous code I used this formula to get the next seat
m_sActiveSeat = (m_sActiveSeat+1)%4;
However this cause the compile error
cannot convert from 'int' to 'enum tile_from_t'
I also tried
m_sActiveSeat++
which would be great if it wrapped around, but still no success.
Is there a simple way to do this rather than using a switch ?
|
|
|
|
|
enums in C++ are basically just named integer constants. They won't wrap around automatically. You can write your own wrapper for Enums (I actually have an article on here somewhere that makes a pretty good cut at it), or you can use const int 's instead. Since you said you were coming from #define 's, I would recommend using the latter.
const unsigned long NORTH = 0;
const unsigned long EAST = 1;
const unsigned long SOUTH = 2;
const unsigned long WEST = 3;
void myFunc(unsigned long direction)
{
switch (direction)
{
case NORTH:
case SOUTH:
case EAST:
case WEST:
doSomething();
break;
default:
throw exception("Oooops!");
}
}
To make sure it is always valid, you could use your modulo operation as well.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Using a const would be a better choice, but unfortunatly it would conflict with other parts of the program that are better of being enums.
I found an excellent article on enum types here[^], which helped me solve the problem.
m_sActiveSeat = SEAT(m_sActiveSeat+1);<br />
if ( m_sActiveSeat > WEST ) m_sActiveSeat = NORTH;
|
|
|
|
|
Hi everyone,
I have a scenario where I wish to send and receive broadcast UDP packets to and from an embedded piece of hardware. The embedded hardware listens for a certain broadcast UDP packet (on port 46051), and responds with a single broadcast UDP packet (to port 46050). The HW and PC are connected directly together. The embedded HW does not transmit anything else. I can transmit a broadcast UDP packet (as seen by Ethereal) and the HW sends its response usually within 375us (which can also be seen by Ethereal) but my app never receives the data. When I connect my PC to another PC running a microsoft UDP sample program (msocupd) which can send broadcast UPD packets, my app does get the data. I noticed that when the 2 PC's were linked together, all sorts of packets were being exchanged (ARP requests, etc..) whereas the embedded HW doesn't transmit anyting. Can what I wish to do be done using sockets?
Thanks in advance,
Jeron
|
|
|
|
|
Did you set IP_ADD_MEMBERSHIP using setsockopt in the application running in your Embedded Device?
Eg:
setsockopt(hSock,IPPROTO_IP,IP_ADD_MEMBERSHIP...
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
Link2006 wrote:Let's take it outside of CP
Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
|
|
|
|
|
Found it...The person who wrote the embedded device assured me that his packet was good...but I found an issue with the 'Total Length' field in the IP header, it was off by 1. As soon as he made the change, my app got the data (my hairline is thankful). Oddly enough Ethereal (which is a great product) didn't make mention of this discrepency. Luckily we had an old Agilent packet analyzer which clued me in. I really appreciate your response.
Jeron
|
|
|
|
|
in my project require to run the exe multiple times,at the same time when new exe of same project is run then immediately previous instatiation of that exe is neceaasry to close.ie when new instance is open then previous insatace should close.please kindely help in my project.
#sanroop#
|
|
|
|