|
|
strcmp() should return 1 , thus making the condition false, thus assigning 0 to x . Do you concur?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I am expecting it to return a negative value, not a zero. What do you think?
MSDN
Strcmp
Return Value
Returns zero if the strings are identical. Returns a positive value if the string pointed to by lpStr1 is greater than that pointed to by lpStr2. Returns a negative value if the string pointed to by lpStr1 is less than that pointed to by lpStr2.
Jon
|
|
|
|
|
Why would you expect it to return a negative value when 't' is clearly greater than 'a'? The function is behaving correctly.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello guys,
I was wondering if someone could tell me the code to accept keyboard shortcuts (either one or two button presses) and a music file will play
e.g I press "1" on the keyboard and a certain sound clip plays
I have been looking at "keybd_event()" and "sendinput()"
with not much luck, I have to add I am a beginner at programming with C++
I hope to develop the program so that there is an option page where you can browse for sound files and assign to different keyboard buttons
I have intermediate knowledge in programming with PHP and i have developed a simple program in c++ before
Thanks in advance
|
|
|
|
|
|
Is there anyway to open a console window, where cout/cin can be used, from within a a Windows forms project? For example, I have a typical GUI interface and would like the option to use a command line interface instead. Using cout/cin does not work because there is no console window to output to or input from. How do I open this window without having to create a completely separate Win32 Console application?
kialmur
|
|
|
|
|
kialmur wrote: Is there anyway to open a console window, where cout/cin can be used, from within a a Windows forms project?
Certainly. See here and here.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Is there no way that I can just open a console and use cout/cin? No forms are open at this point. It seems like quite a complex process just to write to a console.
|
|
|
|
|
When you create a windows app that has a WinMain entry point, there isn't an easy way to create a console. That said, if you want to go the other route (create a console app that spawns your window at some point), it isn't too difficult, but does require some work as far as setting up message loops and such.
Basically, yes, you can have a window with a console. No, it isn't easy to set up.
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
|
|
|
|
|
kialmur wrote: Is there no way that I can just open a console and use cout/cin?
Sure, if you are creating a simple console application. However, since you have a GUI application, the rules change.
kialmur wrote: seems like quite a complex process just to write to a console.
So just wrap it all up into a nice little class, and whenever you want something to be displayed in a console window, instantiate your class, and invoke a few methods. You could even skip the class part, and just put it all in a function (or three). Just call the functions whenever you want something to be displayed in a console window.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Is it possible to prevent the user of an application to use mouse & keyboard for certain operations? Im mean disabling mouse & keyboard for some parts of the program and after that re-enablig that. In VC++, please
|
|
|
|
|
why not simply ignore mouse / keyboard events ?
|
|
|
|
|
Can't you just disable the window using EnableWindow(FALSE), and re-enable it when you're done with your operation?
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
I think i wasn't clear enough. I want that the user of the app. not to be able to use mouse & keyboard to prevent altering data outside the app. That's why I need this.
|
|
|
|
|
I'm having a problem using tile view in my listview control.
It works alright if I'm not using owner data, but if I do use owner data, the listview doesn't draw the label text properly. It looks like it's not bothering to calculate the offset for the label based on the additional lines and just draws at the same spot.
Image of problem
Here are some of the relevant code snippets. Did I miss any particular step?
LVTILEVIEWINFO lvtvi = { sizeof(LVTILEVIEWINFO), LVTVIM_COLUMNS};
lvtvi.cLines = 2;
lvtvi.dwFlags = LVTVIF_AUTOSIZE;
BOOL bRet = m_view.SetTileViewInfo ( &lvtvi );
OnGetDispInfo(...)
{
:
if(pItem->mask & LVIF_COLUMNS)
{
pItem->puColumns[0] = 1;
pItem->puColumns[1] = 2;
pItem->cColumns = 2;
}
:
}
-- modified at 13:58 Monday 24th July, 2006
|
|
|
|
|
Hi,
We have a C++ MFC application GUI that in the user thread, posts a user message using "PostMessage(SET_DLG_DATA_EVENT, 0, (LPARAM)pMsg)" to the GUI's message queue. We've also added a PreTranslateMessage method which gets called by the AFX message pump (CWnd::RunModalLoop) in the GUI thread before it dispatches the message it has removed from the queue; if this PreTranslateMessage method sees the message extracted from the queue is the user message posted in the user thread, it handles it and blocks winproc from seeing the user message.
However, whenever the user message is posted while left mouse button is clicked and held in the menu bar, the posted user message somehow gets routed to the winproc and PreTranslateMessage is not called. The stack trace from CWnd::WindowProc when it gets the user message shows no CWnd::RunModalLoop (the message pump): instead I get
> mfc71d.dll!CWnd::WindowProc(unsigned int message=1234, unsigned int wParam=0, long lParam=3320176) Line 1744 C++
mfc71d.dll!AfxCallWndProc(CWnd * pWnd=0x0012fcd0, HWND__ * hWnd=0x00200610, unsigned int nMsg=1234, unsigned int wParam=0, long lParam=3320176) Line 241 + 0x1a C++
mfc71d.dll!AfxWndProc(HWND__ * hWnd=0x00200610, unsigned int nMsg=1234, unsigned int wParam=0, long lParam=3320176) Line 389 C++
mfc71d.dll!AfxWndProcBase(HWND__ * hWnd=0x00200610, unsigned int nMsg=1234, unsigned int wParam=0, long lParam=3320176) Line 209 + 0x15 C++
user32.dll!77d48654()
user32.dll!77d48723()
mfc71d.dll!_AfxMsgFilterHook(int code=0, unsigned int wParam=2083117216, long lParam=2098704) Line 817 C++
user32.dll!77d49153()
user32.dll!77d4ee88()
user32.dll!77d49196()
ntdll.dll!77f75da3()
user32.dll!77d4a4d3()
user32.dll!77d4a017()
user32.dll!77d49f5b()
user32.dll!77d4a96e()
uxtheme.dll!5ad73f9b()
uxtheme.dll!5ad8aad7()
uxtheme.dll!5ad71ae1()
uxtheme.dll!5ad71c89()
user32.dll!77d4a9a4()
user32.dll!77d4a99a()
user32.dll!77d521ec()
user32.dll!77d52311()
user32.dll!77d48654()
user32.dll!77d48723()
user32.dll!77d4a7eb()
user32.dll!77d4aa95()
mfc71d.dll!CWnd::DefWindowProcA(unsigned int nMsg=1241808, unsigned int wParam=2082654585, long lParam=274) Line 1024 + 0x20 C++
mfc71d.dll!CThreadLocal<_AFX_THREAD_STATE>::GetData() Line 177 + 0xd C++
00000001()
If the mouse button is not held down, everything works fine.
Any ideas why the user message posted to the queue is routed differently while the mouse button is held down in the menu bar (non-client area?)
thanks,
Rob
-- modified at 13:49 Monday 24th July, 2006
|
|
|
|
|
I have this code:
<br />
if (a = 1) dwID = IDC_EDIT1;<br />
if (a = 2) dwID = IDC_EDIT2;<br />
if (a = 3) dwID = IDC_EDIT3;<br />
<br />
GetString(pView, dwID);<br />
And then this function:
<br />
CString GetString(CView *pView, UINT dwID)<br />
{<br />
CString str;<br />
<br />
CWnd *pWndChild = pView->GetDlgItem( (UINT)dwID);<br />
pWndChild->GetWindowText(str);<br />
<br />
return str;<br />
}<br />
If I just called GetString(pView, IDC_EDIT1), the code works. But if I
use:
<br />
if (a = 1) dwID = IDC_EDIT1;<br />
if (a = 2) dwID = IDC_EDIT2;<br />
if (a = 3) dwID = IDC_EDIT3;<br />
I get an "unhandled exception" and it points to this code:
<br />
void CWnd::GetWindowText(CString& rString) const<br />
{<br />
ASSERT(::IsWindow(m_hWnd));<br />
Is there any way I can call
GetString(pView, dwID)
or something like this instead of
GetString(pView, IDC_EDIT1);
Please, any response any one can give me will be greatly appreciated.
Sincerely,
Danielle Brina
|
|
|
|
|
If I understand correctly, you are using a test condition for the following:
if (a = 1) dwID = IDC_EDIT1;
if (a = 2) dwID = IDC_EDIT2;
if (a = 3) dwID = IDC_EDIT3;
If that is the case, you should be using the == operator instead of the = operator.
if (a == 1) dwID = IDC_EDIT1;
if (a == 2) dwID = IDC_EDIT2;
if (a == 3) dwID = IDC_EDIT3;
It's pretty easy to confuse the assignment operator with the equals operator which is 2 consecutive equal signs.
-- modified at 13:27 Monday 24th July, 2006
|
|
|
|
|
I appreciate the reply.
The = is just a typo on my part. Im using == but I still get the error.
|
|
|
|
|
That might have been it. I take back my earlier statement.
|
|
|
|
|
DanYELL wrote: if (a = 1) dwID = IDC_EDIT1;
if (a = 2) dwID = IDC_EDIT2;
if (a = 3) dwID = IDC_EDIT3;
If a was equal to 1 , why would you want the last two statements to be evaluated?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DanYELL wrote: if (a == 1) dwID = IDC_EDIT1;
if (a == 2) dwID = IDC_EDIT2;
if (a == 3) dwID = IDC_EDIT3;
Can you show how 'a' is passed. Possibly it is not going through any of above condition and 'dwID' is having garbage value.
DanYELL wrote: CWnd *pWndChild = pView->GetDlgItem( (UINT)dwID);
and this statement is initializing pWndChild with NULL.
|
|
|
|
|
Hello, perhaps someone can answer this for me without me having to display my entire program.
I am having issues with one of my cin statements getting read in by a user's keyboard input. I am using the debugger in Visual C++ and it appears as though the compiler is skipping this cin statement and moving to the next cout statement. This seems to happen when the program is moving from one function call to another in main(). I found a fix to this by adding 2 consecutive cin statements but I know this is not the correct way to program. Has anyone had a similar experience. If so, how did you handle it.
Thanks,
HRW.
-- modified at 12:56 Monday 24th July, 2006
|
|
|
|
|
How are we expected to offer any reasonable solution without seeing the problematic code? We don't need to see all of it, just the relevant snippet.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|