|
If you're programming in C++, you can use the C++ templated string classes.
typedef struct _mystruct
{
typedef std::basic_string<TCHAR> mystring_type;
mystring_type Name;
mystring_type Addres;
} MyInfo;
pInfo->Name = _T("Mark");
pInfo->Address = _T("Marks's Address");
Of cource saving the data to a file is a totaly different subject; you cann't do anything like write(hFile,pInfo,sizeof(MyInfo)), because it would not make since with this structure (or any structure that contains pointers).
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
for Windows Task Manager, We click Applications to see Running tasks, But
can I write code to see them?
|
|
|
|
|
The EnumProcesses function retrieves the process identifier for each process object in the system.
Use OpenProcess to get process handle.
Use functions like GetModuleFileNameEx , GetProcessMemoryInfo to obtain some information.
Don't forget to call CloseHandle() on the process handle when done.
|
|
|
|
|
|
This is my 1st time in a Forum, so here it goes...
I have something like this
void CChildView::sortData(LPCTSTR sendData)
{
//I want to insert sendData into an array.
//the compiler, visual C++ 6 will not allow me to.
//sendData is only 1 character at a time send from the COM-port.
//I've tried:
strcpy (tempData, sendData);
//and many more to mention
//Also after editing, I want to send it back to:
DispalyData(tempData);
//DisplayData will not accept anything else but the LPCTSTR format.
}
I've been working on this for 2 whole days, 18hrs!!! Could you please help me, I am a beginer in programming, and have read all the reading materials on the net, but don't understand as it's to advance for me.
Thank you.
All the evidence seems to indicate, that the universe has not existed forever, but that it had a beginning, about 15 billion years ago. This is probably the most remarkable discovery of modern cosmology. Yet it is now taken for granted. We are not yet certain whether the universe will have an end. When I gave a lecture in Japan, I was asked not to mention the possible re-collapse of the universe, because it might affect the stock market.
-- Stephen Hawking
|
|
|
|
|
Long
Pointer
Constant
Translates to either Unicode or ANSI
STRing
LPCTSTR lpName = "tomek18";
char cLetter = lpName[3]; or
char cLetter = *(lpName + 3); tomek18 wrote:
//I want to insert sendData into an array.
So what does the array look like?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
void CChildView::sortData(LPCTSTR sendData)
{
TCHAR buffer[1024];
_sntprintf(buffer, 1024, _T("%s"), sendData);
DisplayData(buffer);
}
|
|
|
|
|
typedef wchar_t TCHAR; // UNICODE
typedef char TCHAR; //ANSI, DBCS
typedef const TCHAR* LPCTSTR;
Therefor, if you are compiling a UNICODE program then LPCTSTR is defined as const wchar_t*, otherwise it is defined as const char*.
If want to be able to create ANSI and UNICODE version of your code, then you need to use TCHARs and the macro _T()(or TEXT()), along with the functions define to use TCHARs (normaly they start with _tc???()).
If all you need to work with is ANSI, then you can use plain old C-strings: char, char*, const char*.
size of in BYTEs = (string length in TCHARs)/sizeof(TCHAR).
byte_len = _tcslen(str)/sizeof(TCHAR);
byte_len = strlen(str)/sizeof(char); // equal to strlen()/1
byte_len = wcslen(str)/sizeof(wchar_t); // wcslen(str)/2
Good Luck!
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Does anyone know any common/basic time functions in C / C++?
I want to write a frequency function that will call another function, every set period. For example, if the period was set for every 5 seconds, then the function will 'tic' every 5 seconds.
I notice there is no built-in functions for this sort of clock / tic functionaility. What is the easiest way? Or the best most efficient way or implementing a clock / tic function?
C method first, then if it's better, C++.
|
|
|
|
|
|
I was looking for a non-Visual C++ specific way. Someway by the standard C library. I believe SetTimer() is a Microsoft C++ function.
|
|
|
|
|
SetTimer() just a Windows API. the only other thing I can think of is to spawn another thread and have it execute an infinite loop that calls Sleep() for the amount of milliseconds you need, then call the function you want it to execute
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
Or the secondary thread can call WaitForSingleObject with a timeout.
That way, it is easy to get the thread to STOP if you set an event, or else it will exipre over the itme interval and return WAIT_TIMEOUT . This prevents the need to KILL the thread to get it to stop before the timeout period has elapsed. If you want the thread to respond to messages, then use the MsgWaitForMultipleObjects . Having the thread Sleep() just makes other parts of the application unresponsive and is poor design, such as in system shutdown
The timing will not be terribly precise, but if you can tolerate +-1 second or less, you are probably fine.
|
|
|
|
|
I have seen a lot of discussion and examples on sub-classing existing windows controls (i.e. MFC's CEdit) to override or add your own functionality. However, I have found virtually no information on how Window's native controls are created in the first place. WinCtrl fairy maybe? I realize that they are part of the OS and possibly beyond mere mortals.
We have combo boxes, tree contols, list controls, and so on and I have examined creating windows at the API level, that is CreateWindow(...). Is it possible to create an entirely new type of window/control from scratch? Some insight into the "black-box" of windows and controls would be interesting.
Ross White
|
|
|
|
|
Yes. It all starts with a call to RegisterClassEx . Then you define the icons, menus, window message handler, etc. for your totally new 'custom' window type. Typically all this code and the resources required for the menus, icons, brushes, etc. is put into a DLL and then you export a function that registers these custom windows.
For example, you get a many of the 'normal' classes registered when your MFC application calls InitCommonControlsEx .
|
|
|
|
|
|
Yes. Look at the RegisterClassEx function and the WNDCLASSEX structure. This will define the parameters of your new control such as icons, menues, and window procedure. You will have to write your own WndProc and handle any messages you need to draw the control, handle mouse clicks, etc. You most likely would write this code in a dll and export a function to call RegisterClassEx to register your control class before calling CreateWindowEx to create your control.
Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about about mission statements. -- Peter Gibbons
|
|
|
|
|
Thank all for the input. I will have to go back and do some more home work!!
Ross White
|
|
|
|
|
hello!
can anybody tell me how can i create check box in the group box dynamically.
|
|
|
|
|
Find the window handle of your group box.
Do a Create on the checkbox control window and make sure it is inserted in Z-Order AFTER the group box window. That will effectively place the checkbox 'in' the group box. The Z_Order will affect the tab order, which is one of the criteria the group box uses to determine which controls are part of the 'group'. Also, certain controls must have the WS_GROUP style set, all child controls from one with WS_GROUP set untilt the next one with WS_GROUP set are considered a single group.
For example:
Group Box - WS_GROUP
CheckBox - WS_GROUP
CheckBox - NO WS_GROUP
CheckBox - NO WS_GROUP
CheckBox - NO WS_GROUP
Push Button - WS_GROUP
This makes for four checkboxes all part of same group.
|
|
|
|
|
I am trying to set a different font inside a grid tab. The following code is a snippet of what I’m doing. When I run the application it crashes! Has anyone used the function call SetTabFont? And if so can you share some insight on how to properly use this thing. The commented code is what I’m inputting to try and get my desired response.
Thanks for any help, Steve…
void CProcessGrid::OnSetup()
{
CUGCell cell;
CUGTab mTab;
SetNumberSheets(3);
AddTab("Procedure", 0);
AddTab("Parts", 1);
AddTab("Tools", 2);
SetTabWidth(500);
SetCurrentTab (0);
//************ Change Font Size **********[SMB 06/20/05]
//
//CFont *mFont;
//int fontIndex;
//fontIndex = AddFont("Arial", 8, 2);
//mFont = GetFont(fontIndex);
//mTab.SetTabFont(mFont);
//
//*****************************************************
|
|
|
|
|
Is it possible that the mTab object hasn't been created yet (not a window yet)?
|
|
|
|
|
( in VC6 )
I have a DLL from a 3rd party.
there is only one function in the DLL which is declared like this in the simplist documentation :
int __stdcall Function( long,double*, long , long );<code><br />
<br />
in my code I do this : <br />
<br />
<pre>
typedef int (*FunctionProc)(long , double*, long, long );
double* p;
int iRes = FunctionProc( 1, p, 2, 3 );
}</pre><br />
<br />
When I run this, I get a ESP error telling me the calling convention is not good between the DLL function and the function prototype I use.<br />
<br />
I changed the calling conventions of my sample project from __cdecl to __stdcall ( in the project settings ) and it looks like it works, the Function gets called without crashing.<br />
<br />
Is there a way to "transform" the function calling convention ? <br />
<br />
in my real application, I would like not to change the calling convention if possible, I don't really know the implications.<br />
<br />
Thanks.<br />
<br />
Max.<br />
<br />
<br />
<hr><a href="http://www.thesorus.qc.ca">Maximilien Lincourt</a><br />
Your Head A Splode - Strong Bad
|
|
|
|
|
I'd use __cdecl . It has always worked well for me in the past
|
|
|
|
|
No because the caller has been built with a specified calling convention and the stack must be set up accordingly.
|
|
|
|