wrapper

How to wrap a win32 WndProc into a C++ class?

匆匆过客 提交于 2020-01-24 15:42:51
问题 Is this even possible? For example, let's say I have the following: class Window { private: WNDCLASSEX wc; public: inline WNDCLASSEX getWindowClass() { return wc; } Window(); LRESULT CALLBACK WndProc(HWND hwnd, UINT message, LPARAM lParam, WPARAM wParam); } void RegisterWindow(Window win) { WNDCLASSEX* wc = win.getWindowClass(); RegisterClassEx(wc); } Now, somewhere there is going to be a section (probably in the constructor of the Window class, where it's necessary to assign the WNDCLASSEX a

C++ - Constructing wrapper class with same syntax as wrapped data

我怕爱的太早我们不能终老 提交于 2020-01-24 12:32:57
问题 I'm making a template class that is a wrapper around some type of data. I would like to be able to set / construct this class the same way as I set that data when it's not wrapped. Here's the basic idea: template<typename T> class WrapperClass{ public: T data; WrapperClass(const T& _data) : data( _data) {} // others stuff }; Now with something like an integer, I can do this: WrapperClass<int> wrapped_data = 1; But with a struct or class I don't know how: struct SomeStruct{ int a, b, c;

C++ - Constructing wrapper class with same syntax as wrapped data

拜拜、爱过 提交于 2020-01-24 12:31:47
问题 I'm making a template class that is a wrapper around some type of data. I would like to be able to set / construct this class the same way as I set that data when it's not wrapped. Here's the basic idea: template<typename T> class WrapperClass{ public: T data; WrapperClass(const T& _data) : data( _data) {} // others stuff }; Now with something like an integer, I can do this: WrapperClass<int> wrapped_data = 1; But with a struct or class I don't know how: struct SomeStruct{ int a, b, c;

Wrapper question when containing floating divs

♀尐吖头ヾ 提交于 2020-01-21 04:58:06
问题 I would like to create a, browser centered, bordered, wrapper that autoexpands in height around various divs. When using floats to keep the divs in-line, the wrapper just stops after the first div. Be kind, this may or may not be right way to do this but that's why I'm here. Here is a simple example. <head> <style type="text/css"> <!-- #wrapper { height: 100%; width: 800px; border: 1px solid #000; margin-right: auto; margin-left: auto; } #header { height: 100px; width: 800px; } #column1 {

What is wrong with this __usercall wrapper?

与世无争的帅哥 提交于 2020-01-16 13:13:12
问题 /* * Wrapper from * int func(int a, int b, int c, unsigned int d, signed int e); * to * int __usercall func<eax>(int a<eax>, int b<ecx>, int c, unsigned int d, signed int e); */ int func(int a, int b, int c, unsigned int d, signed int e) { __asm { push e push d push c mov ecx, b mov eax, a call __usercall_func // access violation somewhere inside here add esp, 12 } } 回答1: You cannot perform ret yourself from within an inline asm block, because you don't know what the outer function has done

wrap a noninheritable class in vb.net

守給你的承諾、 提交于 2020-01-15 12:39:09
问题 I would like to use a class Cookie in my namespace for convenience, with the same capabilities as System.Web.Cookie, or better be equivalent. I can't derive from System.Web.Cookie because it is noninheritable... In C, i could simply typedef it to another type, but I don't see any possibility in VB.net other than write a wrapper class that mimics all functions. Is there another way to "rename" a type in VB.net (Framework 4.0)? Edit: I found a solution, to import the class under a different

Making a Text-To-Speech Wrapper in Android

╄→гoц情女王★ 提交于 2020-01-14 04:10:07
问题 I am attempting to create a wrapper class for Google Android's Text-To-Speech functionality. However, I'm having trouble finding a way to have the system pause until after the onInit function has finished. Attached at the bottom is something of a solution I created based on what I found here: Android speech - how can you read text in Android? However, this solution does not seem to work. Any thoughts on why this might not be working, or what would be a good idea in order to make sure that any

Make a wrapper for cout?

血红的双手。 提交于 2020-01-14 02:12:30
问题 So here's an interesting question, How would I make something kinda like a wrapper for cout? I want to be able to add it into a dll so I can throw it into my programs. but the basic syntax of it should be Mything::mesage << "I'm some text" << im_an_int << someclass << mything::endl; or Mything::mesageandlog << "I'm going to print to console, and to a file!" << mything::endl; I can handle most of the internal logic but as to what I should put to even do this. kinda stumped. Possibly make a

void* to Object^ in C++/CLI

时光怂恿深爱的人放手 提交于 2020-01-13 13:49:52
问题 I am working on wrapping a large number of .h and .lib files from native C++ to Managed C++ for eventual use as a referenced .dll in C#. Some of the native C++ functions have a return type of void*. I am not sure how to handle this when I pass back the value to my calling code. For instance: if a C# app calls my dll wrapper, what do I return from the native call: void* start(ThreadFunc,void *, unsigned *); I am currently attempting to box the return in a generic System::Object^ with no luck.

C# database wrapper design

只谈情不闲聊 提交于 2020-01-13 04:41:08
问题 I am designing a database wrapper for C#. Below are the two options I have: Option A: class DBWrapper:IDisposable { private SqlConnection sqlConn; public DBWrapper() { sqlConn = new SqlConnection("my connection string"); sqlConn.Open(); } public DataTable RunQuery(string Sql) { implementation...... } public Dispose() { if(sqlConn != null) sqlConn.Close(); } } Option B: class DBWrapper { public DBWrapper() { } public DataTable RunQuery(string Sql) { SqlConnection sqlConn = new SqlConnection(