|
Win32:
WideCharToMultiByte => Unicode to ANSI
MultiByteToWideChar => ANSI to Unicode
If you're using MFC 7.1:
CStringW strUnicode = L"Blah";
CStringA strANSI(strUnicode);
CStringW = Unicode string
CStringA = ANSI string
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
|
hai..
Thanks for u r quick response. The main problem is when i extract the unicode data it comming in ??????? symbols. How to extract this unicode data.Please let me know.
Thanking you,
E.Veera Raghavendra.
e.veera raghavendra
|
|
|
|
|
I Want to ignore ASSERT Dialog on DEBUG mode using try ~ catch.
How can i do it?
help me pelase...
And sorry for my little English.
thanks..
|
|
|
|
|
You can't, they are different beasts. You can redefine the ASSERT macro, I suppose.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I think you are confusing ASSERT (dialog which comes up due to statements like ASSERT(FALSE) ) and a crash dialog. ASSERT are more of a programmers tool to announce that something is wrong. If you dont want to have ASSERT coming up for an expression evaluating to be FALSE, then just remove them. Simple.
And if you are interested in handling crashes gracefully, then you should have something like
try
{
// Code resulting in probable crash.
}
catch(...)
{
}
|
|
|
|
|
Possibly a good answer, but you gave it to the wrong person.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
>> wrong person
Poor you. I've seen this like 10 times already.
Alex Korchemniy
|
|
|
|
|
Thinking about it furhter - I assume this means you get an ASSERT message in your code when you call an MFC or other function ? You should fix your code, not try to get rid of the ASSERT, which is simply warning you of a problem that will continue to exist.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
thanks for answers.
in fack,
I have errors that can't know problem.
so,
I want to show error dialog that I made, instead of ASSERT message.
How can catch ASSERT message in advance?
This week is dead line of my project.
help me, please...
and sorry for my little English.
Finally, have a nice day!
Thanks...
|
|
|
|
|
I have a 3x5 text box entries. Each are identified by almost the same number but with a different number attached to it. For example, row 1 control IDs are IDC_Row1_1, IDC_Row1_2, IDC_Row1_3, etc. I would like to disable/enable the boxes in a for loop without having to type out each control ID. How do I convert the string into the ControlID recognized by the system? See below.
CString str;
for (i = 1; i <= 3; i++)
{
for (j = 1; j <= 5; j++)
{
str = "IDC_Row" + i + "_" + j;
//how do i convert the string to the control ID value to set its property?
GetDlgItem(str)->EnableWindow(TRUE);
}
}
|
|
|
|
|
Your names are actually constant values, which map to numbers in your resource file. Your best bet is to make sure they are sequential in your resource files, and then you can just use a loop.
Or you can create a vector which contains all the controls, regardless of their values, and a function object to pass to for_each.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
On the other hand, in the event that some other nitwit comes along and does not KNOW they have to be in order, you can declare a static array of UINT in your source file containing the identifiers, and use that as the basis for your looping.
static UINT s_ControlArray[] = {
IDC_CONTROL_1_1, IDC_CONTROL_1_2, IDC_CONTROL_1_3,
IDC_CONTROL_2_1, IDC_CONTROL_2_2, IDC_CONTROL_2_3
};
Use a for loop to access the elements in the array.
The GetDlgItem() would work using those identifier values, and then you can use the EnableItem as you wanted.
|
|
|
|
|
I started giving you a complicated solution (by trying to fix your code) that in the end would not work. Then thought about it for a few seconds and I have come to the conclusion that the best solution is the one Christian has provided above. I have used this method in the past (with buttons -phone dial pad) and it works great.
[EDIT]
One thing to add is I would edit the resource.h file directly.
[/EDIT]
John
|
|
|
|
|
Is there a way on how to use MFC based controls on win32?
|
|
|
|
|
You have the source code for all of MFC, if there's just one bit you want, why don't you build a control based on the source ?
I'm not sure if you can do this or not, I'd imagine it's possible, all MFC controls are Win32 controls at the end of the day, it's just a wrapper.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I'm trying to use Video for Windows to capture images from a webcam on a timed interval (using a WM_TIMER message). To try and capture the image I'm basically using:
capFileSaveDIB(hWndC,"filename.bmp");
This works perfectly well if the application (MFC dialog) is active when the message is fired, but if the window is not active or minized, the image is not capture. I've looked through the VFW documentation on MSDN, but I can't find any mention of this problem.
Any ideas how I can capture the image while the application is minimized?
Thanks
modified 12-Jul-20 21:01pm.
|
|
|
|
|
This is what I'm getting. The code works fine when I create a seperate Windows application, but when I bring the file into my other project I get this weird error. Also it's just a .c file so how can I include it? Do I just #include <waveply1.cpp> so I can use the functions?
--------------------Configuration: 3daudio - Win32 Debug--------------------
Compiling...
WavePly1.cpp
c:\program files\microsoft visual studio\myprojects\3daudio\waveply1.cpp(328) : fatal error C1010: unexpected end of file while looking for precompiled header directive
Error executing cl.exe.
WavePly1.obj - 1 error(s), 0 warning(s)
|
|
|
|
|
Try putting a #include "stdafx.h" at top. What is happening is that you project (as all default VC++ projects) is set to use precompiled headers. "stdafx.h" is your master precompiled header.
|
|
|
|
|
Okay that worked thanks. Now that I have a free-floating .c file, I thought I could just change main() to a regular function. This is what's happening now is that easy to figure out?
--------------------Configuration: 3daudio - Win32 Debug--------------------
Compiling...
3daudioDlg.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\3daudio\3daudioDlg.cpp(222) : error C2065: 'playmain' : undeclared identifier
Error executing cl.exe.
3daudio.exe - 1 error(s), 0 warning(s)
|
|
|
|
|
You are using "playmain" which has not been previously defined. You can't do that.
|
|
|
|
|
Hi,
I new to programming...Pls bare with me for this is really a basic question in pointers..
In my program I have a global variable
char *gz_Nos[10];
I need to assign some strings(like '000001','000002'...) to this array in one of my function and check the values in other function..
so I did as follows..ie my .cpp
char *gz_Nos[10];
mycalss::myclass(){}
mycalss::~myclass(){}
int myclass::func1()
{
char t_str[MAX_STRLEN];
for(i=0;i<2;i++)
{
wsprintf(t_str,"00000%d",i+1);
gz_Nos[i]=t_str;
}
return 1;
}
int myclass::func2()
{
char *sz_no;
int i=0;
.....
sz_no = "000001"
for(i=0;i<2;i++)
{
if(sz_no == gz_Nos[i])
{
MessageBox(0,"Error","Error",MB_OK) ;
return 0;
}
}
}
But here I couldnt see the value of gz_Nos[i] in func2..I am calling func1 first and then func2.And also in func1 if I display the value of gz_Nos[0] it displays '000002'. Where am I going wrong...
Thanks a lot.
|
|
|
|
|
Well for starters you are assigning a local variable (t_str) to your array of strings (gz_Nos), as soon as you exit the function, the compiler unwinds the stack and your left with a corrupt string. Try using something like char* t_str = new char[MAX_STRLEN], and make sure to call delete[] t_str when you no longer need it. Strings, memory and pointers are complicated beasts. Check out some good books, like Stroustrup's novel.
|
|
|
|
|
Hi everybody, i need your help. Im trying to change the desktop wallpaper, but i must use the IActiveDesktop interface, and i dont know what files i must include in the header, in the msdn help, they tell me, that i must include shlobj.h but with that it doesnt work. If some body can help me i will be gratefull.
|
|
|
|
|