|
hy, it didtn helped me a lot, because i need to run c++ code BEFORE i run the setup steps.
i didnt found out how to do this!
|
|
|
|
|
I currently have the job of cleaning up around 3700 warnings. Most i have sorted but this one i am having trouble make go away.
Your help would be most appreciated, thanks in advance.
Code:
hwndStartButton=CreateWindow "button",szLoadStringOne,WS_CHILDWINDOW|WS_VISIBLE|WS_EX_TOPMOST | BS_PUSHBUTTON , (rect.right)/2-100,(rect.bottom+380)/2-50,200,25,hwnd,ISVM_STARTISV,hInst,NULL);
Warnings:
VC++ 6
t_eng1.c(965) : warning C4047: 'function' : 'struct HMENU__ *' differs in levels of indirection from 'const int '
t_eng1.c(965) : warning C4024: 'CreateWindowExA' : different types for formal and actual parameter 10
Info:
ISVM_STARTISV #defined as 214
I have tried casting the 8th param (ISVM_STARTISV) to a HMENU, which supresses the warning, but then the WM_COMMAND does not get sent.
Also i am not using 'CreateWindowExA' and have not included any headers or libraries.
The MSDN documentation for CreateWindow for this parameter shows why i am passing in an int.
MSDN fragment:
hMenu
Handle to a menu, or specifies a child-window identifier depending on the window style. For an overlapped or pop-up window, hMenu identifies the menu to be used with the window; it can be NULL if the class menu is to be used. For a child window, hMenu specifies the child-window identifier, an integer value used by a dialog box control to notify its parent about events. The application determines the child-window identifier; it must be unique for all child windows with the same parent window.
end MSDN
This button gets created dynamically, when it's pressed a WM_COMMAND message needs to be sent, i then need to identify
which button has been pressed.
i have tried :
hwndStartButton=CreateWindow "button",szLoadStringOne,WS_CHILDWINDOW|WS_VISIBLE|WS_EX_TOPMOST | BS_PUSHBUTTON ,(rect.right)/2-100,(rect.bottom+380)/2-50,200,25,hwnd,(HMENU *)ISVM_STARTISV,hInst,NULL);
The compiler now says:
warning C4047: 'function' : 'struct HMENU__ *' differs in levels of indirection from 'struct HMENU__ ** '
-- thanks in advance
|
|
|
|
|
What the MSDN fragment states is correct: this parameter specifies a handle to a menu, or a child-window identifier if WS_CHILD flag is set.
Check your window style definition: you are giving it WS_CHILDWINDOW instead of WS_CHILD. I think the code is a bit picky on this one, eventhough WS_CHILDWINDOW were defined similarly as WS_CHILD. Use WS_CHILD instead.
To eliminate the warning, you can either one of the following calling conventions. The first one does a static conversion, and the latter a static cast:
hwndStartButton = CreateWindow( "button", szLoadStringOne, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, ... , hWnd, (HMENU) ISVM_STARTISV, hInst, NULL);<DIV>
hwndStartButton = CreateWindow( "button", szLoadStringOne, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, ... , hWnd, static_cast<HMENU>( ISVM_STARTISV ), hInst, NULL); I am not completely sure how the first call will behave, but the second one should not give any warnings related to this matter. I might've typoed in there, so be careful when copying it. Also, you tried in your last lines to convert it to HMENU*. But that is not what the function requires. It wants a handle to a loaded menu, not a pointer to it's location. Just pass the ISVM_STARTISV, converting it to type HMENU with either one of the routines stated above.
As you can also see, I have removed the WS_EX_TOPMOST style from the call, as you can only use extended style flags when you use the CreateWindowEx function.
The topmost style is not appliable to a button: it will always be drawn "before" (in front of) it's parent window in Z-order. Otherwise your button would always be shown, even if there was a dialog "between" the parent window and the button. That would look extremely ackward, don't you think ?
I hope this will be help to you. If it doesn't work, post results here for more analysis..
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
The reason you get a warning about CreateWindowExA rather than CreateWindow is that CreateWindow is a #define for CreateWindowA (if UNICODE is not defined), and that CreateWindowA is a #define for CreateWindowExA, passing 0 for the first parameter. Documentation for this version is under CreateWindowEx.
This means that when the compiler complains about parameter 10, you need to fix parameter 9.
You do need to cast ISVM_STARTISV to HMENU. I don't know why your command stops working. Your code should then look like:
hwndStartButton = CreateWindow(
"button",
szLoadStringOne,
WS_CHILDWINDOW | WS_VISIBLE | WS_EX_TOPMOST | BS_PUSHBUTTON,
rect.right / 2 - 100,
(rect.bottom + 380) / 2 - 50,
200,
25,
hwnd,
(HMENU)ISVM_STARTISV,
hInst,
NULL
); (style guide: prefer a reinterpret_cast<hmenu> rather than a C-style cast if using C++).
I don't know why your button should stop working, though. Put a breakpoint in the parent window's WindowProc to see what value gets sent when you click the button.
The final problem is because HMENU is declared
typedef struct HMENU__ * HMENU; if STRICT is defined. If you see an error referring to Hxxx__ in Windows code, remove the two underscores and one * to interpret it properly.
|
|
|
|
|
Thanks Mike for the help. - debugging the Proc definitely helped
My problem lies with the fact i am using the WM_USER constant. Although the range i am using should work for passing messages inside the same Application, it is safer to use the WM_APP: 1024 - 1439 for Identifiers and the System doesn't seem to use this range.
cheers
Carl
|
|
|
|
|
How I can using Visual C++ to control my parallel port output and input.
|
|
|
|
|
Try this site for a reference: http://www.doc.ic.ac.uk/~ih/doc/par/doc/data.html
Also, you might want to attempt to "open the device", just like you'd open a file. Call _open and specify "LPT1" for the file name. You could open a COM port by specifying "COM1" instead. Then just read and write to the device by using _read and _write .
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Check out this example at MSDN.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfiles/html/msdn_serial.asp
Kuphryn
|
|
|
|
|
How can get the all Windows operating system code pages using VC program
kumara
|
|
|
|
|
use GetVersionEx() .
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Use _getmbcp() , or GetCPInfoEx() .
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Hi
Thanks for the reply.
Actually I need to get all the code page names that the OS use
As example like below
This is some
CodePage Codepage name
1250 windows-1250
1251 windows-1251
1252 Windows-1252
1253 windows-1253
1254 windows-1254
1255 windows-1255
1256 windows-1256
1257 windows-1257
1258 windows-1258
I can use "GetCPInfoEx" but this is not giving the format that I mention in above.
If u have solution please tell me know.
Thanks
Kumara
|
|
|
|
|
Use EnumSystemCodePages() .
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
|
Hello,
I want to get all files in specified directory and also in subdirectories using Windows SDK. PPl who know plz send it.
Valan
|
|
|
|
|
There's no direct method, so you'll either have to write your own recursive function, or use an existing class to do it (such as this CFileInfo[^] or this SADirRead[^]).
|
|
|
|
|
Dear All,
I am developing an application for Windows2000 NTFS filesystem specifically in VC++ MFC version 6.0.
I want to get exact path of Info2 located in the recycle bin folder of the specified drive (e.g on my computer it is d:\RECYCLER\S-1-5-21-725345543-1708537768-1957994488-500\Info2)
Can anybody please suggest a way out to get the path of info2 ?
Regards,
Rohit
|
|
|
|
|
To get the IDL of the Recycle Bin folder, use SHGetSpecialFolderLocation(..., CSIDL_BITBUCKET, ...) .
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
I am writing a MDI application where the child windows contain active x controls that request metering information every 100 ms.
When the child window is deactivated they keep requesting metering information so that the user can tile the windows and see the meters updating.
I want to stop the control reuesting data when it is hidden by another window and not visible. Does anyone know how I can tell when a window region is hidden by another window?
WM_PAINT events are only generated when a part of the window which was hidden is exposed again. I want to know when it was painted over so I can stop wasting processing and comms. band width for a control no one can see.
Any suggestions would be most welcome.
|
|
|
|
|
I just spent the evening creating the first C++ app I've written in years, and everything works as expected. Enter a bunch of text, and it emits Morse Code. Except now I've discovered that the system speaker (or whatever it is that the Beep(...) function accesses) can't respond fast enough to make clearly detectable dit/dah tones. Can anyone recommend a source of programmable tones I can use with PlaySound() or some other function which can be programatically altered to change pitch and duration? Or perhaps direct me to instructions on how to construct .wav files on the fly, especially generating the data chunk from some simple algorithm I can write that converts a series of dits and dahs into PCM in a format that can be readily played back?
"Another day done - All targets met; all systems fully operational; all customers satisfied; all staff keen and well motivated; all pigs fed and ready to fly" - Jennie A.
|
|
|
|
|
From . & -> to PCM Data chunks in a few days
Way to go
http://www.codeproject.com/audio/concatwavefiles.asp[^]
looks like this is what you want
Hope it helps
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
It's amazing what one can accomplish with only two fingers and a lot of trial and error. Not to mention the assistance of a few friends!
That looks like part of the solution - thanks!
The harder bit is understanding how to get from an array of values for cos(wt) to a PCM chunk properly scaled and formatted. The pitch has to be variable for aesthetic reasons - some like high, squeaky tones, others lower tones - and the duration has to be varied from 30mS (40 wpm code) to 1200 mS (1 wpm code). That rules out storing a bunch of .wav files and joining them. A decent tradeoff would be to generate files of 10, 20, 50,and 100 mS duration for the selected pitch, then join them to make dits and dahs for the selected word per minute transmission rate.
"Another day done - All targets met; all systems fully operational; all customers satisfied; all staff keen and well motivated; all pigs fed and ready to fly" - Jennie A.
|
|
|
|
|
Wow you can read morse code? I never did manage to master it (which basically closed the entire area of ham radio to me in the late 60s). It didn't matter much to me at the time but latterly that's been a regret... On the other hand, I did make a TV set using a 5BP1 CRT and 6h6's as a voltage doubler for the EHT. That was fun
Rob Manderson
http://www.mindprobes.net
Paul Watson wrote:What sense would you most dislike loosing?
Ian Darling replied.
Telepathy
Then I'd no longer be able to find out everyones dirty little secrets The Lounge, December 4 2003
|
|
|
|
|
Rob Manderson wrote:
I did make a TV set using a 5BP1 CRT and 6h6's as a voltage doubler for the EHT. That was fun
You guys have way too much time in ur hands
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
lol this was back in 1970 after reading an article published in 1957 in the Australian magazine 'Radio, Television and Hobbies' which later became Electronics Australia. To this day I get all misty when I smell rosin.
Rob Manderson
http://www.mindprobes.net
Paul Watson wrote:What sense would you most dislike loosing?
Ian Darling replied.
Telepathy
Then I'd no longer be able to find out everyones dirty little secrets The Lounge, December 4 2003
|
|
|
|
|