|
Just what i needed....
Thank you.
Anil.
|
|
|
|
|
Hi Anil,
The funcitons mbstowcs and wcstombs are documented in MSDN and do exactly
the conversion you are asking about. However when you are implementing
a system that has both chars and wchars you find yourself doing conversions
all over the place just so you can do things like strcmp.
[And instancinting tempory string objects is even worse]
So try the follow code segment to give you the string functions you want.
You will be able to use the function safe_strncpy to copy from either wchar
to char, char to wchar, char to char and wchar to wchar!
I have found this particularly useful for gradually changing chars to wchars
in a project as the other version of the function automatically steps in.
One day I'll write it up to post to CodeProject.
Jules
--- Code begins here, sorry if the format gets broken along the way ----
** Change of plan - the message was too long!
The function header is
template<class s1,="" class="" s2="">
int safe_strncpy(S1* szDest, const S2* szSrc, unsigned int iLen);
template<class s1,="" class="" s2="">
int safe_strncmp(const S1* szA, const S2* szB, int iLen=-1);
template<class s1="">
int safe_strlen(const S1* szString);
template<class s1,="" class="" s2="">
const S1* safe_strstr(const S1* sz1, const S2* sz2);
and you just use either char or wchar to do the work.
Tell me if you are interested and I'll email the FULL template to you.
|
|
|
|
|
I have been using Visual C++ for my development. But two weeks ago, I found that my Visual C++ (MSDEV.EXE) could not be launched. It gaves me runtime error "Abnormal Program Termination for MSDEV.EXE". I have tried several times to uninstall and reinstall the program but to no avail.
I have even reformatted the harddisk, install the Win2000 Pro SP1 (previously I used NT4.0 SP4), then, install VS6.0. And the same error occurred when I start MSDEV.EXE. Others programs like VB or VID run smoothly.
When I install VS6 SP4, it gives me this error:
cannot load package 'devied' ....
Can anyone help me please
|
|
|
|
|
When you say you reformatted your hard disk, I assume you mean that you reformatted a second drive that had Visual Studio on it...
In that case you probably have mangled some sort of registry or system DLL... Sometimes thats hard to recover no matter how many service packs you install. I'd go to Microsoft and download their program regclean and give that a go and try reinstalling.
|
|
|
|
|
Nop! My VS6 and NT4 are reside at the same harddisk. When I reformat my harddisk, that means I have clear the NT4 and VS6 at the same time. However, I do have the second harddisk, that is mainly to store my personal data. May be this harddisk contains some registry information?
I did run the regclean, but the problem still happen.
|
|
|
|
|
By chance do you have Numega's Boundschecker installed? Also, please give the exact error messages as you get them.
|
|
|
|
|
Yes! I remember that I have installed an evaluation copy of Numega BoundChecker. Can you give me clue on how to solve this problem? Or may be there are some helps at Numega website?
The exact error when I run the first installed VS6:
Microsoft Visual C++ Runtime Library:
Runtime Error!
Program: ...\MSDEV98\Bin\MSDEV.EXE
Abnormal Program Termination
After I install the VS6SP4, and run the program, it pop up this message:
Microsoft Visual C++
Cannot load package 'devbied' because its internal version number, or the internal version number of one of its components, does not match the version of the Developer Studio shell.
Do you want to continue?
and when I press the only button 'OK', another message box:
Micosoft Visual C++
DEVBIED
This required file cannot be loaded.
Please re-install Microsoft Visual C++
Thanks!
|
|
|
|
|
For the error that occurred when I first install the VS6, I have found a way to solve it. It is actually the problem of MFC42.DLL. The MFC42.DLL resides on WINNT\System32\ is not compatible with VS6. To solve it, I copy the MFC42.DLL from the VS6 installation CD, and paste it at the same folder as for MSDEV.EXE.
However, when I install the VS6SP4, then problems remains. It cannot load 'devbied' package because of different internal version... can anyone help me, please?
Thanks!
|
|
|
|
|
Finally I have solve the problem that bother me for several weeks!! @#$*+!@
To solve the problem, I do the following 2 steps:
1. Replace the Common folder in Microsoft Visual Studio with the one in VS6 installation CD.
2. Copy the MFC42.DLL from the VS6 installation CD into the same folder as MSDEV.EXE
voila! That simple!
Thanks!
|
|
|
|
|
Try some of the things mentioned in this link (PRB: Resolving DEVBCPX: This required file cannot be loaded Error):
http://support.microsoft.com/support/kb/articles/Q177/4/35.ASP?LN=EN-US&SD=gn&FR=0&qry=cannot%20load%20package&rnk=1&src=DHCS_MSPSS_gn_SRCH&SPR=VCC
|
|
|
|
|
Downloaded VC++ 5.0 projects loaded into my VC++ 6.0 crash on replying yes to the conversion dialog. These projects do not contain MAC targets as noted on the MSDN VC 6.00 bug list.
I first get an access denied to the .dsw file, followed by a sys crash as noted in Norton Antifreeze. Sometimes the conversion will succeed after a few tries.
I have deleted the .ncb, .opt, and dsw file opening only the .dsp file to create the new workspace related files, but the problem still exists.
Any suggestions?
Ron Ginsberg
VC++ 6.0 SP 3
WIN98 (with updates), NT4 at work.
TV Broadcast Engineering Tech
|
|
|
|
|
I have an a final Assignment due for a CS140 course and I really need some help. My professor puts the assignments on the web and the URL for the one I'm having trouble with is: http://www.hello-world.com/MC/CS140/Assignments/A8_sort.htm. It involves having to sort 8 names. I can't get my program to print out an array at all. I'm getting a variety of errors too. If anyone could help me, I would really appreciate it. I'll email you the work I've done so far. I'm kind of desperate here since the assignment is due BY December 18, 2000 so can someone PLEASE help me. Thanks! I would really appreciate it if you could email replies to me at: wa16@juno.com
|
|
|
|
|
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
|
|
|
|