|
Did you try with to add controls to form with code not visual,did you have same problem?
|
|
|
|
|
Not yet.
It's ok in vc6.
I've uninstalled vs2008 just now.
I'll try vs2005 tomorrow.
Thanks all the same.
|
|
|
|
|
I hope you didn't uninstall VS 2008 just because your
controls didn't show up
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Another reason is that it is bit slow and lack of a class wizard at least in the beta version.
I've tried to report the control problem to ms.
|
|
|
|
|
Does anyone know how to retrieve a Hard Disk Serial number from the Hardware.(i.e. one that corresponds(or is supposed to do so) with the label on the Device. (or, for that matter, any other number that identifies a machine.) I am trying to put together some licencing software. Is there any code about I can readlly use free in a small commercial app, whitout delving into too many details.
Happy New Year to All
Bram van Kampen
|
|
|
|
|
Bram van Kampen wrote: Does anyone know how to retrieve a Hard Disk Serial number
Use Win32_PhysicalMedia class of WMI to get the hard disk serial number.
|
|
|
|
|
Naveen wrote: Use Win32_PhysicalMedia class of WMI to get the hard disk serial number.
Thanx
Do you have a brief example
Bram van Kampen
|
|
|
|
|
Bram van Kampen wrote: Do you have a brief example
Sorry i dont have. but i am sure you will find some if you google or check Microsfot script center[^]. Check this [^]link also( its in vb )
|
|
|
|
|
|
dear all
how to read a data file from harddisk to my program? thanks
Li Zhiyuan
8/01/2008
|
|
|
|
|
Do u mean like fscanf() or fread().
|
|
|
|
|
i mean i had a data file in my harddisk, but i should use it in my program...how to read or load the file? thanks.
do u have any code which read one file to program? can i work as a reference. thanks
Li Zhiyuan
5/10/2006
modified on Monday, January 07, 2008 10:01:39 PM
|
|
|
|
|
#include <fstream>
std::ifstream file("C:\\Temp\\hello.txt");
Maxwell Chen
|
|
|
|
|
Without further info I do not realy understand your problem, but, the general procedure is:
Step 1. You should know the fully qualified name of the file you want to read i.e.: CString MyFile="C:\MyDirectory\MyData\DataFile.ext". If you type that as a string in your code(bad Idea, but not your immediate problem) you should type all backslashes double. i.e.:CString MyFile="C:\\MyDirectory\\MyData\\DataFile.ext".
Step 2;
You Open the file, and get a File Handle:
FILE* F =fopen(MyFile,"rb"); The "rb" means that you want to open the file for binary reading, (as opposed to Text Reading, which should be opened for reading with just "r")
Step 3: You find out how big the file is. You move the File Pointer to the End of the File, and ask where it is.
size_t CurPos=ftell(F);// Record the File Pointer
fseek(F,0,SEEK_END)
size_t FileSize=ftell(F);
fseek(F,CurPos,SEEK_SET);// Returns the FilePointer to where it was
Step 4:
Allocate a buffer to hold the File Contents
char* Buf=(char*)malloc(FileSize);
Step 5:
Ensure that there was enough free memory left to Allocate the Buffer
if(Buf==NULL) return ERR_OUT_OF_MEM;
Step 6:
Read the File into the Buffer
fread(Buf,FileSize,sizeof(char),F);
step 7:
Close the File. This is most important, Noone Else can work with the file while you have it open, Even yourself cannot open it a second time.
Step 8:
The contents of your file is now in Buf. Do with it as you like.
Step 9:
When You're done with it, you should 'free' Buf. Unlike say VB, C++ has NO garbage collection service. It is up to you to get rid of memory you no longer need.
Bram van Kampen
|
|
|
|
|
do you have any source code to read data from harddisk and print it on the screen? thanks a lot.
i am reading one book, it is still blur, thanks
Li Zhiyuan
5/10/2006
|
|
|
|
|
Did you use of CFile class?
|
|
|
|
|
i dun use CFile class
Li Zhiyuan
5/10/2006
|
|
|
|
|
hi guys,
i need help on visual c++ coding. does anyone know the coding for x and y coordinates detection. As i needed to detect the mouse pointer. Your reply serve a great help. thx
|
|
|
|
|
Is GetCursorPos()[^] what you're looking for?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
yes it is..
i tried using
POINT pos;
GetCursorPos(&pos);
int x=pos.x;
int y=pos.y;
but when i compile it appear is error.
Compiling...
SetCursorPos.c
C:\Program Files\WiT8.1\customcp\cplib2\src\SetCursorPos.c(10) : error C2143: syntax error : missing ';' before 'type'
C:\Program Files\WiT8.1\customcp\cplib2\src\SetCursorPos.c(11) : error C2143: syntax error : missing ';' before 'type'
Error executing cl.exe.
SetCursorPos.obj - 2 error(s), 0 warning(s)
|
|
|
|
|
Looks like you're missing windows.h.
You may want to use the project wizard to build a Win32 project for you.
Then you'll have a good starting point with the basic required header files
included.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
thx mark..
but i had a new error.
coding:
#include "wcplib2.h"
#include <windows.h>
#include <iostream>
using namespace std;
CorOpRtn myCo_SetCursorPos(CorObj *In, CorObj *Out)
{
POINT pos;
GetCursorPos(&pos);
int x=pos.x;
int y=pos.y;
return COR_OP_OK;
}
Error:
Compiling...
SetCursorPos.c
c:\program files\microsoft visual studio\vc98\include\eh.h(32) : fatal error C1189: #error : "eh.h is only for C++!"
Error executing cl.exe.
SetCursorPos.obj - 1 error(s), 0 warning(s)
Student86
|
|
|
|
|
The error message says it - you'll need to be compiling for C++
to use eh.h
Renaming the source file with a .cpp extension is probably enough.
If not, the /TP compiler option will do it. You can set this for
a project in the project properties/C/C++/Advanced section.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I am creating a class for a dialog that can be used either in modal or modeless form, and I would like to use them both at the same time in a dialog-based app.
The complication is that the modal form and the modeless form use different resources (modal form has an 'OK' and 'Cancel' button, modeless does not) wondering if it's possible to use them in the same application since VS2005 puts the following line in CDialog-derived classes:
[code]
// Dialog Data
enum { IDD = IDD_DX9MATERIAL_DIALOG };
[/code]
which seems to tie the class to the dialog, no? Is it not possible to the use the same class for two dialogs? Or should I just create another version of the class for the two types of docs?
Thanks - @LRG
|
|
|
|
|
@largeinsd wrote: which seems to tie the class to the dialog, no?
Yes. It's only source code....feel free to alter it for your own use
The IDD is used only one place by default - it is passed to the CDialog
constructor. With a little modification you can pass whatever resource ID
you want to the base class.
Another alternative in this case, is to use one resource and show or hide the two
buttons depending on if the dialog is used modal or modeless.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|