|
To create a modal dialog box indirectly, first allocate a global block of memory and fill it with the dialog box template. Then call the empty CDialog constructor to construct the dialog-box object. Next, call InitModalIndirect to store your handle to the in-memory dialog-box template. The Windows dialog box is created and displayed later, when the DoModal member function is called.
|
|
|
|
|
Hello,
Thanks.
I have understood that a block of memory has to be allocated and a DLGTEMPLATE template to be filled.
But how do I fill up the template and how do I allocate block of memory.Is there a site where I can look up.
Prithaa
|
|
|
|
|
prithaa wrote: Can you tell me how to use InitModalIndirect() function of CDialog class?
And what exactly is the meaning of the first parameter of this function.
MFC has provided a class CDialogTemplate . include "afxpriv.h". Documentation for afxpriv says that contents of this file could be altered in the future, but for a demo I will show you how to do this. Look up source code for CDialogTemplate for more information...
Eg:
CDialogTemplate dlgTemplate;
dlgTemplate.Load( MAKEINTRESOURCE( IDD_SOME_DIALOG_ID ));
CDialog dlg;
VERIFY( dlg.InitModalIndirect( dlgTemplate.m_hTemplate, 0 ));
|
|
|
|
|
|
Hello,
When I used the InitModalIndirect(),the function was executed successfully since while debugging it returned 1 a non-zero .
But the dialog box was not displayed on screen even if I called the CDialog::DoModal() function after InitModalIndiect()
Thanks
Prithaa
|
|
|
|
|
Hello, I'm trying to draw a toolbar with icons designed by myself(which I'm very proud of them ). I use CImageList to store my icons then I pass my ImageList to CToolBar to do the rest of work. I did not use LoadToolBar because I wanted to have greater control over buttons and their associated pictures. How should I tell to CImageList to get its hand off my icon and do not place a black background behind them. I want background of my icons be color of my framework.
This is my code...
<br />
m_ImageList.SetBkColor(CLR_NONE);
m_ImageList.Add(LoadIcon(hIcon));<br />
...<br />
m_ToolBar.CreateEx(this, TBSTYLE_FLAT | TBSTYLE_TRANSPARENT, WS_CHILD |WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);<br />
m_ToolBar.GetToolBarCtrl().SetImageList(&m_ImageList);<br />
...<br />
thanks
|
|
|
|
|
You didn't show how you are creating the image list. It needs to be masked...
// assuming icons are 16x16
m_ImageList.Create(16, 16, ILC_COLOR24 | ILC_MASK, 0, 1);
...
m_ImageList.Add(LoadIcon(hIcon));
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
|
Electronic75 wrote: I was wondering what is your mean from the phrase in your signature
That's a quote from the move "Better Off Dead".
Those are skiing instructions (they work for extreme programming as well )
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
THIS WORKS
file is appended with the text "###, 28/06/07, 09:30, 1.736, 1.234"
Message Box correctly reports fileName as expected.
fstream FileDataStream;
// Read Data
FileDataStream.open(fileName, ios::out | ios::app);
// Append Data
FileDataStream<<"###,";
FileDataStream<<(LPCSTR)dateString<<','<<(LPCSTR)timeString<<',';
sprintf(buf, "%.4f,", eTable[5*sel + 2]); // GeskeDose
FileDataStream<
|
|
|
|
|
Looks like I needed to call
FileDataStream.clear();
I think that some error flag is set when the while loop pulls in the EOF marker while reading the file, and that is what causes the problem when you next try to open it.
|
|
|
|
|
Hi, I'm trying to write a simple hello world application with Visual C++ 6.0 and I get the following errors:
Compiling...
Run.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\Test2\Run.cpp(13) : error C2664: 'MessageBoxA' : cannot convert parameter 2 from 'unsigned short [13]' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
Here's my code:
#include <windows.h> // include the basic windows header file
// the entry point for any Windows program
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd)
{
// create a "Hello World" message box using MessageBox()
MessageBox(NULL,
L"Hello World!",
L"Just another Hello World program!",
MB_ICONEXCLAMATION | MB_OK);
// return 0 to Windows
return 0;
}
Any help would be greatly appreciated regarding what's the error.
|
|
|
|
|
try simply :
MessageBox(NULL,"Hello World!","Just another Hello World program!",MB_ICONEXCLAMATION | MB_OK);
|
|
|
|
|
Thanks a lot, it worked. Sorry I'm kind of new. Do you know why? All I did was copy the code from a textbook. Thanks again.
|
|
|
|
|
"Hello" is a simple string of char's - which is constant in your code
so it's a const char *
typing L"Hello" , specially the L before the string realises a special casting(*), but i don't know
in which type. Regarding your error-message the L does make a casting to a short array
* Casting: is a forcing of a data-type into another type
For example
int number = 69; --> a real number data type
char test = (char)number; --> forces the number 69 into a char, regarding the ASCII-Coding, the Number 69 is the character 'E'
test will store 'E' after this line of code
|
|
|
|
|
Because the macro L"..." (as you put it as argument to the MessageBox function) tells the compiler that the string literal (so the string that is between "") should be considered as a UNICODE string. A UNICODE string is a string that can display a larger set of character but also means that each character is encoded on two bytes instead of one. This string type is 'incompatible' with a standard char array (you cannot exchange from one to the other).
In fact, you won't have any error if you specified that UNICODE is enabled for your project. But in the case of VC6, the default is that UNICODE is disabled. If you used Visual Studio 2005, UNICODE is enabled by default.
Now, to avoid these kind of errors, use the _T macro instead. It will automatically take care of UNICODE setting enabled or not.
|
|
|
|
|
MSDN [^]states: To specify a string of type wide-character (wchar_t[]), precede the opening double quotation mark with the character L. For example:
wchar_t wszStr[] = L"1a1g";
hence your string is a wide-character one, while the MessageBoxA (note the A suffix) is the ANSI version of the MessageBox , choosen by the compiler because you are making an ANSI build (the default one, on VC6). MessageBoxA accepts only ANSI strings (i.e. char * ) while your strings are wide (i.e. unsigned short * ), hence the error shows up.
Perhaps the sample code you used assumes you're using a later version of Visual Studio, that has UNICODE builds as default.
Hope that helps.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
|
Hi,
Can anybody help me out how to create a "Data Source Name" from my C++/MFC program?
I am using VC++8, Windows XP, and MySQL.
Pradosh
|
|
|
|
|
try
SQLConfigDataSource(...) API
|
|
|
|
|
I was trying to get some help on SQLConfigDataSource(). I am not able to find any help in MSDN. Which header file it is belonging or so on so!
Currently I am using a reverse way to do the same:
<br />
system("odbcconf /S CONFIGDSN \"MySQL ODBC 3.51 Driver\" \"DSN=MyDsn | Description=test dsn | SERVER=10.1.1.4 | User=user1 | Password=pw1 | Database=MyDb\"");<br />
But I want to use any API to do the same.
Pradosh
|
|
|
|
|
imp lib: ODBCCP32.lib
include file : "odbcinst.h"
ref:
http://www.codeguru.com/cpp/data/mfc_database/microsoftaccess/article.php/c1135/
|
|
|
|
|
extern "C" int sqlClass::createDSN(char* driver, char* keyword)
{
int returnValue;
try
{
returnValue = SQLConfigDataSource(NULL,ODBC_ADD_SYS_DSN,(LPSTR)driver,(LPSTR)keyword);
if (returnValue)
return 0;
return -1;
}
catch(...)
{
MessageBox(NULL,"Exception Occured - DSN not created","Error Occured",MB_ICONHAND);
return -2;
}
}
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
I'm curious....does SQLConfigDataSource throw exceptions? You have it wrapped in a try block.
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Hi all,
I need some good file encryption with password.Can you some suggest some thing.Please note that I am new to VC++
Dana
|
|
|
|