|
Hi sir,
I am not able to open the dialog.
Its showing the error as.
"C:\DataBase\Sample.MDB" is not a valid path.Make sure that the path name is spelled correctly and that you are connected to the server on which the field resides.
void CMainView::OnAdminlist()
{
AdminList.DoModal();
}
When i go into that function,i am getting error as
i.e \MFC\SRC\DLGCORE.cpp
TRY
{
AfxHookWindowCreate(this);
Brekpoint error---------> if (CreateDlgIndirect(lpDialogTemplate,
CWnd::FromHandle(hWndParent), hInst))
{
if (m_nFlags & WF_CONTINUEMODAL)
{
DWORD dwFlags = MLF_SHOWONIDLE;
if (GetStyle() & DS_NOIDLEMSG)
dwFlags |= MLF_NOIDLEMSG;
VERIFY(RunModalLoop(dwFlags) == m_nModalResult);
}
if (m_hWnd != NULL)
SetWindowPos(NULL, 0, 0, 0, 0, SWP_HIDEWINDOW|
SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
}
}
CATCH_ALL(e)
{
DELETE_EXCEPTION(e);
m_nModalResult = -1;
}
END_CATCH_ALL
Actually first the application was in MS-Access DatBase.I changed it to SQL.
Now i am not getting what is this error.
Note : nd one more thing is
If i am trying to open the application for the first time(If the DataBase which is created with MSAccess) name is changed
For ex: I rename the database from"DatBase" to "DataBase1"
I am getting the error message before opening the application.
>"C:\DataBase\Sample.MDB" is not a valid path.Make sure that the path name is spelled correctly and that you are connected to the server on which the field resides.
If i dnt change the DataBase name i am not getting this error message when i open the application
Where may be the problem
Any idea will be helpful
Thanks
Raj
modified on Saturday, July 10, 2010 12:43 AM
|
|
|
|
|
You seem to be getting confused between two different errors.
1. If your path to the database file is not correct you will get the errors above. The error message could not be more clear as to the cause of the problem, the solution is simply to ensure that the file exists and the path in your program is correct.
2. AdminList.DoModal(); is giving an error trying to create a modeless dialog. This does not make much sense since a call to DoModal(); should show a modal dialog. However the information you provided does not show how AdminList has been created.
It's time for a new signature.
|
|
|
|
|
My application used the Grid Control[^] to show the data from database. Some of these field need to show in Thai language text but it become to unreadable text.
Normally, The Thai text can show in this Grid and this application already used for 1 year in the hotel reception computer with have no such problem.
Recently, many customers' hotel ask for use this computer for send the e-mail, so each person will set up some windows setting for make it support to they own language such as Japanese, Chinese etc.
In this point, it is the root cause of the problem that make the Thai language text can not show in the Grid control again.
The problem only happen in this application for another application such as Word, Notepad etc. It still can show the Thai text normally.
Please, anybody help me to solve this problem.
Note:
The application write by MFC from VS2005 and run on windows XP profressional SP3
|
|
|
|
|
having a quick look at the Grid Control, I see it does have Unicode support - but maybe you have to enable it ?
'g'
|
|
|
|
|
I've never used GDI in any of my projects.
But had some programming introduction to it.
Since I've been using Windows 7, I'm trying to build a new project with Direct2D.
It compiles and runs, but it doesn't display anything!
Does anyone have any experience, what could be the reason?
#include <Windows.h>
#include <d2d1.h>
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hCurrInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASS SetFileTime = {};
SetFileTime.hInstance = hCurrInstance;
SetFileTime.lpfnWndProc = WndProc;
SetFileTime.lpszClassName = L"D2D";
RegisterClass(&SetFileTime);
CreateWindow(
L"D2D",
L"Direct2D",
WS_OVERLAPPEDWINDOW|WS_VISIBLE,
100, 100, 800, 600,
NULL,
NULL,
hCurrInstance,
NULL);
MSG WindowMessages = { };
while (GetMessage(&WindowMessages, NULL, 0, 0))
{
TranslateMessage(&WindowMessages);
DispatchMessage(&WindowMessages);
}
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_CREATE:
{
ID2D1Factory* pD2DFactory = NULL;
D2D1CreateFactory(D2D1_FACTORY_TYPE_MULTI_THREADED, &pD2DFactory);
RECT rc;
GetClientRect(hwnd, &rc);
ID2D1HwndRenderTarget* pRT = NULL;
pD2DFactory->CreateHwndRenderTarget( D2D1::RenderTargetProperties(),
D2D1::HwndRenderTargetProperties(hwnd, D2D1::SizeU( rc.right - rc.left, rc.bottom - rc.top)),
&pRT);
ID2D1SolidColorBrush* m_pLightSlateGrayBrush = NULL;
pRT->CreateSolidColorBrush( D2D1::ColorF(D2D1::ColorF::LightSlateGray), &m_pLightSlateGrayBrush);
D2D_RECT_F OriginalRect;
OriginalRect.left = 10.f;
OriginalRect.top = 10.f;
OriginalRect.bottom = 100.f;
OriginalRect.right = 100.f;
D2D1_ROUNDED_RECT RoundedRect;
RoundedRect.rect = OriginalRect;
RoundedRect.radiusX = 1.0f;
RoundedRect.radiusY = 1.0f;
ID2D1RoundedRectangleGeometry* Card = NULL;
pD2DFactory->CreateRoundedRectangleGeometry(RoundedRect, &Card);
pRT->BeginDraw();
pRT->FillRoundedRectangle(&RoundedRect, m_pLightSlateGrayBrush);
pRT->DrawRoundedRectangle(&RoundedRect, m_pLightSlateGrayBrush);
pRT->EndDraw();
return 0;
}
case WM_CLOSE:
{
DestroyWindow(hwnd);
return 0;
}
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
}
|
|
|
|
|
You don't handle the WM_PAINT message, in which all the drawing code should be put. You have put everything in WM_CREATE, which is called when the window is being created.
I suggest you read the following article[^] to get a basic understanding of how it works.
|
|
|
|
|
Hi
I am in the process of learning FIX protocol using QuickFix, I am following the example which is given in the documentation,however I am getting an error during build in one file which is part of the quickfix header file.
Can anyone please let me know if I am missing anything in my project configuration. Just as an FYI I did follow all the instruction in quickfix website to set up a C++ project.
Regards
Arup
Error:
---------------------
<br />
1>c:\project\quickfix\quickfix_c\quickfix\include\quickfix\exceptions.h(260) : error C2664: 'FormatMessageW' : cannot convert parameter 5 from 'char [2048]' to 'LPWSTR'<br />
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast<br />
Code of Exceptions.h. The error is in line 260 which is as follows:
<br />
#ifdef _MSC_VER<br />
error = WSAGetLastError();<br />
char buffer[2048];<br />
FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, NULL, error,<br />
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),<br />
buffer, 2048, NULL );<br />
return buffer;<br />
#else<br />
Exceptions.h
-------------------------
<br />
<br />
<br />
<br />
<br />
#ifndef FIX_EXCEPTIONS_H<br />
#define FIX_EXCEPTIONS_H<br />
<br />
#include <string><br />
#include <stdexcept><br />
#include "Utility.h"<br />
<br />
namespace FIX<br />
{<br />
<br />
struct Exception : public std::logic_error<br />
{<br />
Exception( const std::string& t, const std::string& d )<br />
: std::logic_error( d.size() ? t + ": " + d : t ),<br />
type( t ), detail( d )<br />
{}<br />
~Exception() throw() {}<br />
<br />
std::string type;<br />
std::string detail;<br />
};<br />
<br />
struct DataDictionaryNotFound : public Exception<br />
{<br />
DataDictionaryNotFound( const std::string& v, const std::string& what = "" )<br />
: Exception( "Could not find data dictionary", what ),<br />
version( v ) {}<br />
~DataDictionaryNotFound() throw() {}<br />
<br />
std::string version;<br />
};<br />
<br />
struct FieldNotFound : public Exception<br />
{<br />
FieldNotFound( int f = 0, const std::string& what = "" )<br />
: Exception( "Field not found", what ),<br />
field( f ) {}<br />
int field;<br />
};<br />
<br />
struct FieldConvertError : public Exception<br />
{<br />
FieldConvertError( const std::string& what = "" )<br />
: Exception( "Could not convert field", what ) {}<br />
};<br />
<br />
struct MessageParseError : public Exception<br />
{<br />
MessageParseError( const std::string& what = "" )<br />
: Exception( "Could not parse message", what ) {}<br />
};<br />
<br />
struct InvalidMessage : public Exception<br />
{<br />
InvalidMessage( const std::string& what = "" )<br />
: Exception( "Invalid message", what ) {}<br />
};<br />
<br />
struct ConfigError : public Exception<br />
{<br />
ConfigError( const std::string& what = "" )<br />
: Exception( "Configuration failed", what ) {}<br />
};<br />
<br />
struct RuntimeError : public Exception<br />
{<br />
RuntimeError( const std::string& what = "" )<br />
: Exception( "Runtime error", what ) {}<br />
};<br />
<br />
struct InvalidTagNumber : public Exception<br />
{<br />
InvalidTagNumber( int f = 0, const std::string& what = "" )<br />
: Exception( "Invalid tag number", what ),<br />
field( f ) {}<br />
int field;<br />
};<br />
<br />
struct RequiredTagMissing : public Exception<br />
{<br />
RequiredTagMissing( int f = 0, const std::string& what = "" )<br />
: Exception( "Required tag missing", what ),<br />
field( f ) {}<br />
int field;<br />
};<br />
<br />
struct TagNotDefinedForMessage : public Exception<br />
{<br />
TagNotDefinedForMessage( int f = 0, const std::string& what = "" )<br />
: Exception( "Tag not defined for this message type", what ),<br />
field( f ) {}<br />
int field;<br />
};<br />
<br />
struct NoTagValue : public Exception<br />
{<br />
NoTagValue( int f = 0, const std::string& what = "" )<br />
: Exception( "Tag specified without a value", what ),<br />
field( f ) {}<br />
int field;<br />
};<br />
<br />
struct IncorrectTagValue : public Exception<br />
{<br />
IncorrectTagValue( int f = 0, const std::string& what = "" )<br />
: Exception( "Value is incorrect (out of range) for this tag", what ),<br />
field( f ) {}<br />
int field;<br />
};<br />
<br />
struct IncorrectDataFormat : public Exception<br />
{<br />
IncorrectDataFormat( int f = 0, const std::string& what = "" )<br />
: Exception( "Incorrect data format for value", what ),<br />
field( f ) {}<br />
int field;<br />
};<br />
<br />
struct IncorrectMessageStructure : public Exception<br />
{<br />
IncorrectMessageStructure( const std::string& what = "" )<br />
: Exception( "Incorrect message structure", what ) {}<br />
};<br />
<br />
struct DuplicateFieldNumber : public Exception<br />
{<br />
DuplicateFieldNumber( const std::string& what = "" )<br />
: Exception( "Duplicate field number", what ) {}<br />
};<br />
<br />
struct InvalidMessageType : public Exception<br />
{<br />
InvalidMessageType( const std::string& what = "" )<br />
: Exception( "Invalid Message Type", what ) {}<br />
};<br />
<br />
struct UnsupportedMessageType : public Exception<br />
{<br />
UnsupportedMessageType( const std::string& what = "" )<br />
: Exception( "Unsupported Message Type", what ) {}<br />
};<br />
<br />
struct UnsupportedVersion : public Exception<br />
{<br />
UnsupportedVersion( const std::string& what = "" )<br />
: Exception( "Unsupported Version", what ) {}<br />
};<br />
<br />
struct TagOutOfOrder : public Exception<br />
{<br />
TagOutOfOrder( int f = 0, const std::string& what = "" )<br />
: Exception( "Tag specified out of required order", what ),<br />
field( f ) {}<br />
int field;<br />
};<br />
<br />
struct RepeatedTag : public Exception<br />
{<br />
RepeatedTag( int f = 0, const std::string& what = "" )<br />
: Exception( "Repeated tag not part of repeating group", what ),<br />
field( f ) {}<br />
int field;<br />
};<br />
<br />
struct RepeatingGroupCountMismatch : public Exception<br />
{<br />
RepeatingGroupCountMismatch( int f = 0, const std::string& what = "" )<br />
: Exception( "Repeating group count mismatch", what ),<br />
field( f ) {}<br />
int field;<br />
};<br />
<br />
struct DoNotSend : public Exception<br />
{<br />
DoNotSend( const std::string& what = "" )<br />
: Exception( "Do Not Send Message", what ) {}<br />
};<br />
<br />
struct RejectLogon : public Exception<br />
{<br />
RejectLogon( const std::string& what = "" )<br />
: Exception( "Rejected Logon Attempt", what ) {}<br />
};<br />
<br />
struct SessionNotFound : public Exception<br />
{<br />
SessionNotFound( const std::string& what = "" )<br />
: Exception( "Session Not Found", what ) {}<br />
};<br />
<br />
struct IOException : public Exception<br />
{<br />
IOException( const std::string& what = "" )<br />
: Exception( "IO Error", what ) {}<br />
};<br />
<br />
struct SocketException : public Exception<br />
{<br />
SocketException()<br />
: Exception( "Socket Error", errorToWhat() ) {}<br />
<br />
SocketException( const std::string& what )<br />
: Exception( "Socket Error", what ) {}<br />
<br />
std::string errorToWhat()<br />
{<br />
#ifdef _MSC_VER<br />
error = WSAGetLastError();<br />
char buffer[2048];<br />
FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, NULL, error,<br />
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),<br />
buffer, 2048, NULL );<br />
return buffer;<br />
#else<br />
error = errno;<br />
return strerror( error );<br />
#endif<br />
}<br />
<br />
int error;<br />
};<br />
<br />
struct SocketSendFailed : public SocketException<br />
{<br />
SocketSendFailed() {}<br />
SocketSendFailed( const std::string& what )<br />
: SocketException( what ) {}<br />
};<br />
<br />
struct SocketRecvFailed : public SocketException<br />
{<br />
SocketRecvFailed( int size )<br />
: SocketException( size == 0 ? "Connection reset by peer." : size < 0 ? errorToWhat() : "Success." ) {}<br />
SocketRecvFailed( const std::string& what )<br />
: SocketException( what ) {}<br />
};<br />
<br />
struct SocketCloseFailed : public SocketException<br />
{<br />
SocketCloseFailed() {}<br />
SocketCloseFailed( const std::string& what )<br />
: SocketException( what ) {}<br />
};<br />
<br />
<br />
}<br />
<br />
#endif //FIX_EXCEPTIONS_H<br />
<br />
|
|
|
|
|
The posting of all that code was unnecessary. You simply have a Unicode issue. See here for more.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
The important bit is the error message:
"c:\project\quickfix\quickfix_c\quickfix\include\quickfix\exceptions.h(260) : error C2664: 'FormatMessageW' : cannot convert parameter 5 from 'char [2048]' to 'LPWSTR' 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast"
It looks like you're compiling your code with _UNICODE defined. When that happens FormatMessage gets replaced by FormatMessageW which expects it's parameters to be wide characters. As rest of the code seems to be assuming that they're using narrow characters there's a type mismatch.
If Visual Studio check that for the project you've selected "use multi-byte character set" rather than "use unicode character set" and the problem will go away. You might like to also contact the programmers that maintain the library you're using and suggest they document the problem (or switch their code to use wide characters as narrow ones have been dead on Windows for some time now).
Cheers,
Ash
|
|
|
|
|
Please mark this code as Resolved. I would like to thank all for helping me out.
|
|
|
|
|
Hi,
I am getting the following error when I am building my project in Visual Studio 2005.
Error 134 error C2440: 'static_cast' : cannot convert from 'LRESULT (__thiscall CCancelUIThread::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)' d:\CBSTellerLatest\IDManager\CancelThread.cpp 138
I am not getting any error when I runm the same code on Visual Studio 6.0
The Code is as Follows
Code in .H file
afx_msg LRESULT OnStepProgress(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnSetText(WPARAM wParam, LPARAM lParam);
Code in .CPP file
BEGIN_MESSAGE_MAP(CCancelUIThread, CWinThread)
ON_MESSAGE(CM_PROGRESS_STEPIT, OnStepProgress)
ON_MESSAGE(CM_PROGRESS_SETTEXT, OnSetText)
END_MESSAGE_MAP()
And the function definations.
Please help me out.
Thanks In Advance
|
|
|
|
|
What is line 138?
Have you tried:
ON_MESSAGE(CM_PROGRESS_STEPIT, &CCancelUIThread::OnStepProgress)
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Ummm - a CWinThread is not a CWnd, so it can't have ON_MESSAGE handlers. It *can* have ON_THREAD_MESSAGE handlers, though…so use those instead...
The reason VC6 doesn't complain is that its compiler is so lax at checking and enforcing static typing rules. That's a bad thing, m'kay, 'cause it means there can be many latent, potential bugs left in your code.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
Hi All,
I had Extracted a DLL from a CAB file(Installation package) and edited it using VS2005 to translate some captions in String Table from English to French language(for testing my installation package to support other language) and Saved.
Using the above DLL we are re-creating a Translated Kit(Installation package) and installed it in a fresh machine, After successful installation of my software, While trying to access the above mentioned translated DLL, MFC crash occurs.
The same DLL(Compiled and Build using existing source code in VS2005) with all above actions(translating the string table entries)is working fine.
Can anybody tell me what i am missing / anybody faced similar kind of issue?
Note: I had tried accessing other DLLs to translate the string table entries and corresponding DLLs are accessed without any errors.Also The project properties of both the DLLs(Working/Not Working) are similar.
Thanks in advance.
Thirumalesh
Never Never Never Give Up!
|
|
|
|
|
Hi, I want to Automate MS Word 2010 to extract text with the following code. but I get run-time error "A null reference pointer was passed to the stub."
am I doing something wrong?
CString strDocFile(L"C:\\a.doc");
COleVariant covTrue((short)TRUE), covFalse((short)FALSE), covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
CApplication appObj;
if(!appObj.CreateDispatch(L"Word.Application"))
{
AfxMessageBox(L"could Not Create The Application Object");
return;
}
appObj.put_Visible(FALSE);
CDocuments docsObj(appObj.get_Documents());
CDocument0 docObj;
COleVariant oleStrFile(strDocFile.GetString(),VT_BSTR);
LPDISPATCH pIDoc = docsObj.Open(
oleStrFile,
covFalse,
covFalse,
covFalse,
covOptional,
covOptional,
covFalse,
covOptional,
covOptional,
covOptional,
covOptional,
covTrue,
covOptional,
(long)0,
covOptional,
covFalse
);
docObj.AttachDispatch(pIDoc);
docObj.Activate();
docObj.Select();
CSelection selObj(appObj.get_Selection());
CString docText = selObj.get_Text();
docObj.Close(covOptional, covOptional, covOptional);
docsObj.Close(covOptional, covOptional, covOptional);
appObj.Quit(covOptional, covOptional, covOptional);
modified on Friday, July 9, 2010 8:48 AM
|
|
|
|
|
Is part of the quiz guessing on what line the error occurs?
My guess is that the file L"C:\a.doc" does not exist, and Open fails which sends a null reference to AttachDispatch.
Have you tried opening the file named L"C:\\a.doc" instead?
You don't seem to like checking on return values much.
|
|
|
|
|
Of course I miss type that in the forum, in my program i retreve the filename from CFileDialog.
I ame sure of file path and file existance.
|
|
|
|
|
So what about checking return values?
|
|
|
|
|
Of course I did , I just simplify the code for the forum, the open method of CDocuments throw the exception and I use the following method instead of Open and It works correctly but again I don't know why the previous one doesn’t work.
LPDISPATCH pIDoc = docsObj.Open2000(
oleStrFile,
covFalse,
covFalse,
covFalse,
covOptional,
covOptional,
covFalse,
covOptional,
covOptional,
covOptional,
covOptional,
covTrue
);
|
|
|
|
|
From what I can find[^]
this
covOptional,
(long)0,
covOptional,
covFalse
should be this
covOptional,
covOptional,
(long)0,
covOptional,
|
|
|
|
|
Of course what you mentioned is related to older versions of office type libraries
What i used is Microsoft Word 14.0 Object Library <8.5> which has diffrent interface for Open Method, and OpenConflictDocument parameter is not supported.
But there are other alternative open methods that implement older parameters, Like:
docsObj.OpenOld(...)
docsObj.Open2000(...)
docsObj.Open2002(...)
the last one is what you mentioned but it result in error too.
Only the Open2000(...) method work with out problem but it doesnot support docx documents.
|
|
|
|
|
Hi,
I am tring to pass a structure from one process to another process via file mapping (shared memory).
I am able to get all varibales but unable to get the pointer value defined in dirrerent process.
I think memory addresses are relative to local to that process...How can I access same memory in diffrent process.
|
|
|
|
|
You are correct that addresses are only valid in the context of its process. You would have to put that data into shared memory as well.
|
|
|
|
|
|
Have a look at Ash's reply on serializing data below.
|
|
|
|
|