|
We'll help you to learn, and figure out your problems yourself, but we're not going to do your work for you.
Why don't you try instead to post your problem, any errors you get (be specific) and what you're having problems with.
|
|
|
|
|
I'm sorry. I should have been more specific. OK, I need to make a prog that sorts 8 names. Sounds simple enough but there's some added variables such as stopping the count if the user doesn't enter anything.
Here's the code of what I've done so far:
//Assignment 8
//Will Atkinson
//This is not the completed version!
#include<iostream.h>
#include <string.h>
void getName(char* name)
{ cout<<"Enter a Name: ";
cin.getline(name, 8, '\n');
if(strlen(name)==7)
cin.ignore(100,'\n');
} //getName
readAllNames(char list [] [20])
{ int i=0;
getName( list [i] );
while((i<20)&& (strlen(list[i])>0))
{ i++;
getName( list [i] );
} //while
return i;
}//readAllNames
void printAll(char list[20][20], int c)
{ for (int i=0; i
|
|
|
|
|
Note to anyone reading Will's post, it's been mangled by the browser, you'll have to "View Source" to see the entire message, especially the area in question.
You have a fundamental misunderstanding of arrays.
Your problem in printAll is because you are telling it to print only one character, and the 20th character in the array at that, which is probably empty or garbage.
Remember that list[20][i] references only a single character, not the array of characters.
Hopefully that's enough information to allow you to figure out your problem.
BTW, note to Chris: You have GOT to fix this angle bracket problem. Anyone entering <'s often confuses the browsers.
|
|
|
|
|
Thank you very much. I appreciate your help and will try your suggestions. I realize that my understanding of arrays is not extremely thorough, the situation being that my class only covered them in the last couple of classes. Thank you for taking the time to read my question.
|
|
|
|
|
Thanks so much for your help so far but I was wondering if you could tell me why I'm getting an error message with this program. Is my compiler screwed? or is it my code?
//Assignment 8
//Will Atkinson
//This is not the completed version!
#include<iostream.h>
#include <string.h>
void getName(char* name)
{ cout<<"Enter a Name: ";
cin.getline(name, 10, '\n');
if(strlen(name)==9)
cin.ignore(100,'\n');
} //getName
readAllNames(char list [] [20])
{ int i=1;
getName( list [i] );
while((i<20)&& (strlen(list[i])>0))
{ i++;
getName( list [i] );
} //while
return i;
}//readAllNames
void printAll(char list[][20],int c)
{ for (int i=0;i
|
|
|
|
|
Since you don't say which error messages you're getting, it's hard to tell.
Also, your code is getting mangled by the browser and is not easy to read in some places (look at printAll).
What errors are you getting?
|
|
|
|
|
How to program a DirectX screensaver with scrnsave.lib dependency as this presents no access to WinMain function?
What is thread base rendering?
Amit.
|
|
|
|
|
When I create a ownerdraw combobox,
the hight of the edit field become a few pixels
higher than the same combobox without ownerdraw.
Does anybody have a idea to adjust this.
thanks
|
|
|
|
|
I have three windows in the screen, two are dialogs and are placed there in order to show some information (those are modeless), the third one is a property sheet that is modal.
I don't understand why if I create all the dialogs in the same way one can't be reached even if you clicks over it with the mouse, and the other can be reached.
Do you know some way to create the modeless dialogs in a modeless way?, I would like only that the property sheet would be a modal one, but I've used PS.DoModal() and this don't seems to work.
Thank you in advance and please, excuse my english I'm just a begginer with it.
|
|
|
|
|
I think you're misunderstanding what "modal" means. When a dialog or prop sheet is modal, its parent window is disabled until the dialog is closed.
What I think is happening is, you have a dialog as your main window, with another modeless dialog and a model prop sheet. Since the prop sheet disables the main dialog (its parent), you can't do anything in the main dialog until you dismiss the prop sheet.
--Mike--
http://home.inreach.com/mdunn/
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
--Buffy
|
|
|
|
|
Hi every body,
I use in a MFC app a class that allowing to display bmp image as background in Dialog.
My bmp image is store as ressource. To show my dialog i use this this statement in OnInitDialog event :
SetBitmap(IDB_MYBMP);
I want to change this image at run time like this :
SetBitmap( IDB_MYBMP_2 );
Can anybody say me how to re- call this function at run time and change the background image ?
Thanks in advance
|
|
|
|
|
Create an int variable ( these ID's are just ints ), set the value to IDB_MYBMP, IDB_MYBMP_2, &tc. ) based on whatever condition you want to change it, and use the variable in SetBitmap.
Christian ( using someone elses PC )
|
|
|
|
|
Hello all
I am wrestling with a strange occurance in Visual C++ and being a newby to it I hope you guys can help.
What I have is 3 differant ways a usercan input the same data , either by a spin control, a slider bar or an edit control box. My goal is to have it where if one is adjused the others adjust as well. I have the code down for a change in the slider bar the edit and spin adjust to that value. If the editcontrol is box is used for entering data then both the sldier and the spinbox are updated as well
BUT when i try and build the function for the ON_SpinChange function I encounter a new problem. The code compiles just fine, however when i run it I get a gray box that pops up saying the following
DEBUG Assertion failed yadda yadda with 3 butons to IGNORE, RETRY or ABORT. and i do no know why this happens
the code for on SpinControlChange
is exactly the same as the OnEditControlChange , just differant data names.
here s the code for both
//on user inputting data into edit control box
void CTripCalculatorDlg::OnChangeEdit1()
{
CString SomeValue;
//value input into edit control = speed2
m_speed2.GetWindowText(SomeValue);
//Convert to an int
int speed2 = atoi(LPCSTR(SomeValue));
//adjust the progress bar position
m_progress.SetPos(speed2);
//adjust the slider bar position
m_slider.SetPos(speed2);
//Adjust the spinvalue
m_spin.SetPos(speed2);
m_spinvalue.SetWindowText(LPCTSTR(SomeValue));
} //THIS ALL WORKS FINE
//on input intothe spincontrol instead of using the spin arrows
void CTripCalculatorDlg::OnChangeSpeed()
{
CString SomeValue2;
//value input into spin control = speed
m_speed.GetWindowText(SomeValue2);
//Convert to an int
int speed = atoi(LPCSTR(SomeValue2));
//adjust the progress bar position
m_progress.SetPos(speed);
//adjust the slider bar position
m_slider.SetPos(speed);
//Adjust the editcontrol box
m_speed2.SetWindowText(LPCTSTR(SomeValue2));
}//THIS GIVES ME THE ASSERTION ERROR BOX
what is the differance betweent hese 2 codes that cause the assertion error?
i am perplexed
thank you in advance
Ed Storey
|
|
|
|
|
Where is the assert failing? When it fails, click Retry and the debugger will drop you at the failed assert. It's probably in MFC, so there should be comments there that explain what's wrong.
--Mike--
http://home.inreach.com/mdunn/
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
--Buffy
|
|
|
|
|
Which line of code in OnChangeSpeed(..) is causing the assertion?
When you get the assertion, the message in the Abort/Retry/Ignore message box should tell you where the assertion is coming from. You can then track it back through the call stack.
Without knowing more about where the message is coming from and when you are receiving it, I would assume that it is coming off the initial dynamic data exchange operation when your dialog is being created. If this is the case, then you can try one (or both ) of:
Replace:
m_speed.GetWindowText(SomeValue2)
With:
if (::IsWindow(m_speed.GetSafeHwnd()))
{
m_speed.GetWindowText(SomeValue2)
}
Replace:
m_speed2.SetWindowText((LPCTSTR)SomeValue2)
With:
if (::IsWindow(m_speed2.GetSafeHwnd()))
{
m_speed2.SetWindowText((LPCTSTR)SomeValue2)
}
If this fixes your problem, then you will no that your routine is getting called before your control windows are actually getting created.
Ronald L. Russell Jr. (Ron)
rrussell@ygrest.com
|
|
|
|
|
ok the lines of code it does not like are similar to this one
_AFXCMN_INLINE int CProgressCtrl::SetPos(int nPos)
{ ASSERT(::IsWindow(m_hWnd)); return (int) ::SendMessage(m_hWnd, PBM_SETPOS, nPos, 0L); }
where the
ASSERT(::IsWindow(m_hWnd));
line exists.
I did what you suggested andthrew in a couple message box warnings to see where it goes BONK
I am guessing what is happening is that the code for OnChange is operating before the window is built. I can only assume the reason why this is happening is that when i declare the spin box my default value is 65 and so maybe at that moment it goes down to run this piece of code. However i can understand why it would do this because shouldnt the control box be fully built prior to the program running the onchange function.
i can onl assume i have to go into where i first declare the spinbox and its default value and throw the code in after this but this will only work then once on the initial loading and not if the user changes it later.
Or is there a way i can do this?
|
|
|
|
|
Note that the assertion is getting thrown because ::IsWindow() is failing in the CProgressControl::SetPos(..) member.
This tells you for sure that the progress control has certainly not been created the first time this function has been called.
Try the following:
Replace:
m_progress.SetPos(speed);
With:
if (::IsWindow(m_progress.GetSafeHwnd()))
{
m_progress.SetPos(speed);
}
Replace:
m_slider.SetPos(speed);
With:
if (::IsWindow(m_slider.GetSafeHwnd()))
{
m_slider.SetPos(speed);
}
With these modifications, you should not have to alter you architecture too much, and it should work as soon as the controls are created.
The code is being called before within the context of the dynamic data exchange function (i.e. your dialog's DoDataExchange(CDataExchange* pDX)). The first time this function is called, the controls have not yet been created, so the modifications I have suggested to not hurt you. Once the controls have been created and you can intereact with them, then the ::IsWindow() function will succeed for each and you should get the desired effect.
Ronald L. Russell Jr. (Ron)
rrussell@ygrest.com
|
|
|
|
|
I have seen several articles on various sites about how to prevent an application from showing on the taskbar. Can anyone point me at some information on how to hide an application from the tasklist as well?
|
|
|
|
|
This is a fragment of VB code I've found on the Internet. It is simple to understand and to port it to VC++. I didn't write this code, but I've tried it, and it works!
The author is Andrew Thomas
This is the original URL :
http://www.visual-statement.com/vb/Tips/dsk16.txt
By: Andrew Thomas
To hide your application from the task list,
you must register your program as a service.
This is done by passing the process ID of
your application to the RegisterService API.
Declarations
Copy the following code into the declarations section of a module:
Public Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Public Declare Function GetCurrentProcess Lib "kernel32" () As Long
Public Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As Long
Public Const RSP_SIMPLE_SERVICE = 1
Public Const RSP_UNREGISTER_SERVICE = 0
Procedures
To remove your program from the Ctrl+Alt+Delete list, call the MakeMeService
procedure:
Public Sub MakeMeService()
Dim pid As Long
Dim reserv As Long
pid = GetCurrentProcessId()
regserv = RegisterServiceProcess(pid, RSP_SIMPLE_SERVICE)
End Sub
To restore your application to the Ctrl+Alt+Delete list, call the
UnMakeMeService procedure:
Public Sub UnMakeMeService()
Dim pid As Long
Dim reserv As Long
pid = GetCurrentProcessId()
regserv = RegisterServiceProcess(pid, RSP_UNREGISTER_SERVICE)
End Sub
Don't forget to unregister your application
as a service before it closes to free up
system resources by calling UnMakeMeService.
|
|
|
|
|
Thank you for your response, but I am sorry I was not clearly describing what I am trying to do in my last post.
I am looking for a way, on Windows NT, to hide an application's icon from the ALT+TAB list. If anyone knows how this can be accomplished, I would appreciate the information.
Ronald L. Russell Jr. (Ron)
rrussell@ygrest.com
|
|
|
|
|
I want to have a background image for the List View Control,this list view control is inside a dialog(which is office 97 wizard - propertysheet).
I have set the background image for the dialog, using the constructor of wizard97 property sheet.
I wanted to have the transparency effect for the list view control, I tried setting the extended style option of transperency for the list view control,but it did not work.
So, I tried using SetBkImage function, so that i can have different bitmap for the list view control. But, the image is applied to the background of the dialog,(which is overriding the bitmap set using the c'tor of wiz97) instead of the list view control.
It would be great to have this working.
Thanks in advance.
Cheers
Kannan
|
|
|
|
|
How can I update resources under Windows 89/Me???
In the Win NT or 2000 it's very easy :
1.BeginUpdateResources
2.Update Resources
3.EndUpdaterResources.
But How can I make the same under Windows 89/Me???
|
|
|
|
|
I want to create a borderless window without title bar,I try
set the CreateWindow's parameter dwStyle to WS_VISIBLE only,but the window be created also have title bar and border.
thanks for any help!
by the way,pardon my poor english.
|
|
|
|
|
Basically, you want WS_VISIBLE | WS_POPUP. Here's some code (taken out of context) that I use. It will create a little rectangular window near the uppper left of your screen that is hard to see unless you throw in a little drawing code. From here, everthings up to you - title, border, menus, whatever.
m_wndSession is a class member derived from a CWnd. It it used to create a kiosk effect by sizing itself to the screen and overriding the ususal drawing fns.
This code just shows creation and makes it black so you can see it. (As I say, this code is out of context).
I register a new class here so I can get ownership of the device context, because this is a greedy and selfish window and definitely not a team player.
CString csWndClass = AfxRegisterWndClass(CS_OWNDC,
0,
0,
0);
if(!(m_wndSession.CreateEx(WS_EX_LEFT,
(LPCTSTR)csWndClass,
"Session Window",
WS_VISIBLE|WS_POPUP,
10,10,100,20,
NULL,
NULL
))) {
AfxMessageBox("Failed to Create Session Window)");
return;
}
CBrush cbr(RGB(0,0,0));
CDC* pDC = m_wndSession.GetDC();
pDC->SelectObject(cbr);
RECT rect = {0,0,1500,1500};
pDC->FillRect(&rect,&cbr);
m_wndSession.Invalidate();
...
|
|
|
|
|
how do i make a dialog hidden *before* it gets shown?
|
|
|
|
|