|
hello,
I just want to know how to generate a random number on 4 bytes, I saw that rand returns an int but it's too short for my purposal, any suggestion? In my project I DON'T use MFC, I searched on codeproject but all I found was MFC sample, thanks
Paolo
|
|
|
|
|
Paolo Ponzano wrote:
generate a random number on 4 bytes
Do you mean that the range of random random numbers should span values that fit in 4 bytes? If so, you could just use rand() after seeding it with a random (or as random as you can get) int .
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
i jus tried my 1st c++ to read from a text file to input into an edit box.
Line by line.
How can i do it?
|
|
|
|
|
Hi,
IF U want To show Entire Content Of Text File To EditBox
Use "RichText Box".
Then use "LoadFile()" Method Display Content.
by
baijumax
|
|
|
|
|
Hi,
here code from MSDN Try this
void LoadMyFile()
{
// Create an OpenFileDialog to request a file to open.
OpenFileDialog* openFile1 = new OpenFileDialog();
// Initialize the OpenFileDialog to look for RTF files.
openFile1->DefaultExt = S"*.rtf";
openFile1->Filter = S"RTF Files|*.rtf";
// Determine whether the user selected a file from the OpenFileDialog.
if(openFile1->ShowDialog() == System::Windows::Forms::DialogResult::OK &&
openFile1->FileName->Length > 0)
{
// Load the contents of the file into the RichTextBox.
richTextBox1->LoadFile(openFile1->FileName, RichTextBoxStreamType::PlainText);
}
}
by
baijumax
|
|
|
|
|
I am trying to create sound effects triggered from switches via parallel port. I want to use MIDI since it doesnt use too much processor resources. But I dunno how to generate sounds (e.g. drum / piano sounds) using MIDI. Does anybody know this?
Programming or Die?
----C++ 4 ever-----
|
|
|
|
|
|
I have problem with that. I use BitBlt at OnDraw(), the print preview was OK, but it prints nothing
<italic>Work hard and a bit of luck is the key to success.
|
|
|
|
|
|
Here is my codes to make a dll:
// =======================================================
// common.h -- header for dll and app.
// =======================================================
#ifndef COMMON_H
#define COMMON_H
#include "iostream"
using namespace std;
#ifdef DLL
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT __declspec(dllimport)
#endif
// export or import a class definition
class DLL_EXPORT test
{
public:
test() : m(5){}
void print() { cout<< "m = " << m <<endl; }
public:
="" int="" m;
};
="" export="" or="" import="" a="" function="" ..
dll_export="" void="" test_interface(test*="" ptest);
#endif
="" =="===================================================
//" main.cpp="" --="" imp="" for="" dll="" ;="" with="" d="" "dll"="" out:"test.dll"
="" "common.h"
void="" ptest)
{
="" ptest-="">print();
}
And the testing app here:
// =====================================================
// app.cpp -- testing "test.dll"
// =====================================================
#include "windows.h"
#include "common.h"
typedef void (* INIT_PROC)(test* pTest);
int main(void)
{
test t;
HMODULE hModule = ::LoadLibrary("test.dll");
if(hModule)
{
INIT_PROC proc = (INIT_PROC)::GetProcAddress(hModule,
"test_interface");
if(proc)
{
(*proc)(&t);
}
::FreeLibrary(hModule);
}
return 0;
}
There is an error when building app.cpp:
app.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public:
__thiscall test::test(void)" (__imp_??0test@@QAE@XZ)
Debug/test_app.exe : fatal error LNK1120: 1 unresolved externals
I cound't fix it. Plz help. Thanks very much.
|
|
|
|
|
First off, you're using dynamic loading (run-time loading), so the DLLEXPORT and DLLIMPORT statements are unnecessary at the class definition. You should remove these, because you are not exporting/importing this class's objects.
Also, instead of using __declspec , create a module definition file (.DEF) and write the exported function in there. This allows you to control the exact name by which the function is exported. See MSDN for details on how to use a definition file. If you use a definition file, remove the __declspec entries. The definition file is only required at the DLL project. The EXE project does not require it, because the GetProcAddress will search the DLL export table for the specified exported function.
Otherwise the code looks intact and working.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I would like to create a gateway software solution (with Visual C++ 6.0):
Some machines are connected over ethernet to a server (control PC).
On the control PC (Windows NT) OPC is imitated in one direction (out),
from the other direction I will get some Information from another OPC (in,
OPC machines).
How can I realize that problem??
Exist there any software for gateway solutions ?
Perhaps can i download any software ?
|
|
|
|
|
hi
i want to implement drag and drop. what i want is when some one drops a file on my exe icon it will process that file.
swarup
|
|
|
|
|
You can make an application which is a container. The process of opening the file is done by serialize
<italic>Work hard and a bit of luck is the key to success.
|
|
|
|
|
First off you'll need to call DragAcceptFiles() . Then you'll need to handle the WM_DROPFILES message.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I wrote an application using Visual C++ which uses a database written in Access. I access this database through ADO. It seems this application works fine under XP, 2000 and ME, however I have been told be people using this application under 98SE and NT they are having database issues. So far the database issues are SQL queries that have incorrect syntax, for example "SELECT FROM ORDER Description as" where the correct syntax should be "SELECT * FROM ORDER BY Description asc". I'm not sure why this is happening. Is it possible that NT and 98 might need an additional library so it understands ado? Is ADO compatible in 98 and NT? Do I have to access the database differently for 98 and NT?
Thanks!
|
|
|
|
|
i don`t get it, what happened?
brchris wrote:
for example "SELECT FROM ORDER Description as" where the correct syntax should be "SELECT * FROM ORDER BY Description asc".
Did your app build the wrong query?
<italic>Work hard and a bit of luck is the key to success.
|
|
|
|
|
it must have. I built the error screen that comes up, and I double checked with the guy who received the error screen to make sure that query string was 100% correct as he sees it. So according to him, my app is building wrong query strings on NT. Very bizarre.
|
|
|
|
|
How do you build the string. I had this kind of problem long ago.
<italic>Work hard and a bit of luck is the key to success.
|
|
|
|
|
I build it using the following psuedo code
CString SQL;
SQL.Format("SELECT <fields> FROM where ...");
open table using ADO class.
In a sense I am building them using the CString method and the Format method for pretty much all of my SQL queries.
Thanks!
|
|
|
|
|
Why do you use Format?
My query was:
CString query;
query="SELECT FROM table there var1='";
query+=var; //var is a variable
query+="'";
I think you should debug it. Hope this helps
<italic>Work hard and a bit of luck is the key to success.
|
|
|
|
|
Format seems like an easier way to accomplish the same task you wrote above. It's possible Format could be causing it but why would it remove hard coded values? The string in question is code like this
SQL.Format("SELECT * FROM AG_ERAS ORDER BY Description");
Albiet, it would be interesting to see what this does if I coded it
SQL = "SELECT * FROM AG_ERAS ORDER BY Description;
but that seems odd. Both do exactly the same thing. Unless NT has problems with CString.Format.
I will test the theory though.
Thanks!
|
|
|
|
|
brchris wrote:
SQL = "SELECT * FROM AG_ERAS ORDER BY Description;
Don`t forget with the closing
SQL = "SELECT * FROM AG_ERAS ORDER BY Description";
<italic>Work hard and a bit of luck is the key to success.
|
|
|
|
|
Changing the SQL.Format(...) to SQL = "..."; had no effect.
|
|
|
|
|
Have you try to debug it. What is the query when you debug it. Can I see the code? Maybe I can help
<italic>Work hard and a bit of luck is the key to success.
|
|
|
|