|
I have a dialog app.
i work with a menu:
CMenu * menu = this->GetMenu();
menu->CheckMenuItem(ID_XXX, MF_BYCOMMAND | MF_CHECKED);
and so,so. - and i have a boolean variable that i modify on each click.
Then i have to hide the menu. SetMenu(NULL). Then when i load it again,now it executes all the commands, but it does not check or uncheck any items... what could i do ?
Thanks.
|
|
|
|
|
This is a working example:
CMenu m_menu;
BOOL CYourDlg::OnInitDialog()
{
...
m_menu.LoadMenu(IDR_MENU1);
SetMenu(&m_menu);
...
}
void CYourDlg::OnMenuXXXCommand()
{
CMenu * menu = GetMenu();
if(menu)
{
CMenu* pPopup = menu->GetSubMenu(0);
if(pPopup->GetMenuState(ID_XXX,MF_BYCOMMAND)&MF_CHECKED)
pPopup->CheckMenuItem(ID_XXX, MF_BYCOMMAND | MF_UNCHECKED);
else
pPopup->CheckMenuItem(ID_XXX, MF_BYCOMMAND | MF_CHECKED);
}
void CYourDlg::OnButtonClick()
{
if(GetMenu())
SetMenu(NULL);
else
SetMenu(&m_menu);
}
Regards,
Andrzej Markowski
|
|
|
|
|
I am working on a voip application where a hardware say board with its own channel configured
are to be used.
I am making a cli (cmd line interface) which accepts only a proper syntax.
If teh syntax z found correct. ..it connect itself to the board and does as reqd.
To further illustrate, if the cmd comes like :
" Open Channel <y>, Dial the destination number xxxxx ,Play a file "WelcomeMsg.pcm"It should open a particular channel ,dial the number and on getting connected,it shud play the file.
I ve my cli n the board ready.
But i fail to connect the 2.
I suppose, I shud take the board as my server and connect the cli(client) thru a socket.
This cli application has 2 be on multi wrkstations all connecting to board.
If u understood my question cud u plz oblige with a clarification n assure if i m going right path.
amit mishra
|
|
|
|
|
I have to do a program that reads from a file and copies that text file to a new one and time how long the process takes to do so. The program copies the files correctly but does not display the time correctly. I will show the entire code since it is pretty small. Right now the duration is equal to finish time - start time / CLOCKS_PER_SEC. The output will say
The process took 1202590843 seconds to complete, but when i step through it and put a watch on duration it shows the correct time like 11.567000000
#include <iostream.h><br />
#include <windows.h><br />
#include <stdio.h><br />
#include <time.h><br />
<br />
#define BUFFER_LEN 200 // # of bytes to read/write<br />
<br />
<br />
void main(int argc, char *argv[]) <br />
{<br />
clock_t start,finish;<br />
double duration;<br />
<br />
char buffer[BUFFER_LEN + 1];<br />
<br />
DWORD dwShareMode = 0;
LPSECURITY_ATTRIBUTES lpFileSecurityAttributes = NULL;
HANDLE hTemplateFile = NULL;
<br />
<br />
HANDLE sourceFile;
DWORD numberOfBytesRead;<br />
LPOVERLAPPED lpOverlapped = NULL;
<br />
HANDLE sinkFile; <br />
DWORD numberOfBytesWritten;<br />
<br />
start=clock();
<br />
sourceFile = CreateFile (<br />
"C://Constitution.txt",<br />
GENERIC_READ,<br />
dwShareMode,<br />
lpFileSecurityAttributes,<br />
OPEN_ALWAYS,<br />
FILE_ATTRIBUTE_READONLY,<br />
hTemplateFile<br />
);<br />
<br />
if(sourceFile == INVALID_HANDLE_VALUE) <br />
{<br />
fprintf(stderr, "File Open operation failed\n");<br />
ExitProcess(1);<br />
}<br />
<br />
sinkFile = CreateFile (<br />
"C://NewVersionConstitution.txt",<br />
GENERIC_WRITE,<br />
dwShareMode,<br />
lpFileSecurityAttributes,<br />
CREATE_ALWAYS,<br />
FILE_ATTRIBUTE_NORMAL,<br />
hTemplateFile<br />
);<br />
<br />
if(sinkFile == INVALID_HANDLE_VALUE) <br />
{<br />
fprintf(stderr, "File Open operation failed\n");<br />
ExitProcess(1);<br />
}<br />
<br />
while<br />
(<br />
ReadFile(<br />
sourceFile, buffer,<br />
BUFFER_LEN, &numberOfBytesRead,<br />
lpOverlapped<br />
)<br />
&&<br />
numberOfBytesRead > 0<br />
) <br />
{<br />
WriteFile(sinkFile, buffer, BUFFER_LEN,<br />
&numberOfBytesWritten, lpOverlapped);<br />
}<br />
<br />
CloseHandle(sourceFile);<br />
CloseHandle(sinkFile);<br />
<br />
finish=clock();
duration=(double)(finish-start) / CLOCKS_PER_SEC;<br />
printf("The process took %d ",duration);<br />
printf("seconds to complete\n");<br />
<br />
ExitProcess(0);<br />
<br />
}
|
|
|
|
|
%d in printf is for int's etc. not doubles. Have a look at the format spec for printf and see what to use for doubles. Might be %f but you need to check.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Yes that was it, thanks a lot!
|
|
|
|
|
The program now outputs duration however, this is something I dont understand.
If I run the program normally, meaning without debugging(stepping through it) it says the process takes 0.08000 seconds but if I insert a breakpoint when the file is closing and debug it, it will say the process takes 24.795 secs to do.
When I was debugging I put a watch on duration and that was the 24.795 was the correct output. If I run it without the debugging it says 0.08. How or why does debugging change the value of the variable duration?
|
|
|
|
|
Hi!
How can I get the path (read: executable file) to the default browser for http:// links?
I tried to get the .htm key in the registry, but this isn't the default browser for http:// links. And no, I cannot just use ShellExecute, I really need the executable file.
Any ideas??
Thanks and best regards,
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
|
Its not on win2k nor win 2003 ;/
|
|
|
|
|
Hi. Are there any special compiler settings for visual C++ related to memory management for active-x DLLs writeen in C++?
my DLL is accessed from visual basic application and for even simple calls, seems to be growing by 50K everytime it calls a simple function. I have checked and double checked my malloc/frees. I do use send message api SendMessage to talk back to a visual basic component... but nothing more other than that.
somebody told me about some "release memory" option somewhere..... but i cannot find anything.
Another thing. If i compile with "Multithreaded" it works fine on WinXP and 2000. If i compile with "Multithreaded DLL" it works on XP and strange things happen on 2000. Im compiling on windows xp box.
if i pass a BSTR (by reference) from my DLL to visual basic. the VB app is responsible to free it, correct?
thankz....
beercoder
|
|
|
|
|
What is c++ and visual c++ is there a differance. what is better. does microsoft make both. what one is used to make 3d games
thx
|
|
|
|
|
Hello,
C++ is the language, Visual C++ is one IDE that can be used to develop C++ applications...
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
i hv asked a milion ppl with no use...i need to call an bitmap image in a c++ program and then accssing it's matrix of colors. if anyone could help i would be so greatful and thankful...
your's faithfully
|
|
|
|
|
Try to find hire:
http://www.coding-zone.co.uk/cpp/articles/140101imgproc.shtml
http://www.flounder.com/bitmapinfo.htm
|
|
|
|
|
how i can make my programe change data with another applications for examble how i can get and give data from my programe to internet explorer or any programe by using MFC dialog Box?
|
|
|
|
|
Hai,
I'm doing a dialog based app in win32 vc++. I want to click my button using the mouse right button...how should i do this..pls help if anybody have any ideas..
|
|
|
|
|
Hello,
Just out od curiosity, why do you post the same question as M81?
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
I am the same person...
When I posted using the name M81, it said that the message cannot be posted because of duplicate name. So I changed to M66 and posted again..After when I checked I saw both of the message posted..i dont know what went on..sorry for that..I am not registered..I just peeped in and posted my question.
I am using win32..anyway i figured out a way using subclassing..
thanks a lot.
|
|
|
|
|
I need to write an app that receives video frames through my firewire port. When these frames are in my VRAM I need to set some pixels and then view this particular frame.
Is this possible on a modern PC?
What references are there for this subject? I'm not interested in the audio or any other video source, I just need Firewire..I guess this will be directshow right? I checked some examples on this site but they don't show my video directly.
|
|
|
|
|
How could I do this? I have tried the following, but I get debug assertion errors and the image does not get placed on the button.
<br />
HRESULT hResult;<br />
CImage buttonImage;<br />
hResult = buttonImage.Load("path...");<br />
if (FAILED(hResult)) {<br />
CString fmt;<br />
fmt.Format("Error loading image");<br />
AfxMessageBox(fmt);<br />
}<br />
HBITMAP imageHandle;<br />
buttonImage.Attach(imageHandle);<br />
myButton.SetBitmap(imageHandle);<br />
myButton.UpdateWindow();<br />
Any help would be appreciated. Thank you!
|
|
|
|
|
I'm not sure if I have your solution since I can't see a call stack. But I find it peculiar that you try to attach and update the myButton window even when the image fails to load. If the image doesn't load, you print an error but then you still try to attach the image to the button anyway. That should be within else {} in association with the if{FAILED(hResult)){ .... }. have you debugged and actually stepped through the code to verify whether or not the failure case is being taken? If so, have you seen the call stacks? What kind of info are you seeing in the call stack window while debugging? A lot of times, there is a useful comment in the MFC code where the ASSERT method causes the exception; if you are running in debug mode using visual studio.
Good luck!
Shawn
|
|
|
|
|
Thanks for the reply. When I copied the code over I removed some of it that wasn't really relevent, and I took out the return statement. At any rate, I have run the code through the debugger and I don't get any errors. The image loads fine, but it just does not show up on the button. I will check the call stack tomorrow when I get a chance and post my results.
|
|
|
|
|
I have a whole project in VC++ which has data being stored in binary format using the usual CArchive class. I need to have this data written in xml format without touching the present code i have. So i need to have a wraper class which would store/load data in xml format.
What would be the best way of doing this?
Need urgent help on it.
sv42
|
|
|
|
|
My first thought was to inherit from CArchive, make a CXmlArchive, but overriding the lower level
Save, Load, etc functions. But CArchive is non-virtual, so that is a dead end.
Another option is to Archive into a memory "file", or a temp file and then parse that into XML.
I assume you know the binary format?
Iain.
|
|
|
|